I am trying to extract first element from a dictionary built as follows:
vocab=vectorizer.vocabulary_
{k: v for k, v in sorted(vocab.items(), key=lambda item: item[1],reverse=True)}
Output:
{'zum': 887,
'yet': 886,
'written': 885,
'write': 884,
'worlds': 883,
'world': 882}
I tried next(iter(vocab))
, but it extracts only the first item. I would need the whole list as I want to build a new pandas dataframe with this list.
Desired output:
['zum',
'yet',
'written',
'write',
'worlds',
'world']