TeoK
TeoK

Reputation: 501

select one element from list of values in column dataframe pandas

all,
My input:

logs = pd.DataFrame({'foo':['A','B','C','D'],'bar':[[12,13,14],[10,9,11],[1,2,3],[4,5,6]] })

I trying extract specific element from column where data is list of values. For example I need extract from column bar where first row A, first value 12 in list of [12,13,14]. And in continue run some loop per all list to extract and assign each element of list in new values and do it over all dataframe. So my code:

logs.iloc[0:1,1].values[0]

And I expect get 12, but it doesn't happen

Upvotes: 0

Views: 2281

Answers (1)

amir Reza Seddighin
amir Reza Seddighin

Reputation: 182

enter image description here

you can use it and do something like it

Upvotes: 3

Related Questions