I have a pandas series which is as follows:
series = pd.Series([100, 70, 50], index = ['Brazil', 'France', 'UK'])
I want to retrieve a tuple from the first row with the label as a string and 100,
('Brazil', 100)
It's similar to this post , but because I'm dealing with a list and not a dataframe I haven't managed to make their solution work.
Thanks!
Convert Series.items
to list:
print (list(series.items()))
[('Brazil', 100), ('France', 70), ('UK', 50)]
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.