I am trying to extract all values only and change it to dataframe
My code:
miss = pd.DataFrame({'currency': x, 'balance': miss.values()})
Output:
balance
currency
SNIP (0.007275)
TEM (15.97)
1WO (6.51)
The output is not correct as it seems that it is still in dict type as demonstrated by the output into an excel sheet where it is written dict_values([0.02706])
in each excel cell. Could you help me to create the correct dataframe please.
Use list comprehension if miss.values()
has one element lists:
miss = pd.DataFrame({'currency': x, 'balance': [x[0] for x in miss.values()]})
Or pandas altrnative with indexing str[0]
:
miss = pd.DataFrame({'currency': x, 'balance': miss.values()})
miss['balance'] = miss['balance'].str[0]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.