Applying conditional statements on lists stored in Dataframe cell
--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game 5
--
Chapters
00:00 Applying Conditional Statements On Lists Stored In Dataframe Cell
01:15 Accepted Answer Score 1
01:33 Thank you
--
Full question
https://stackoverflow.com/questions/7410...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #list #dataframe #booleanlogic
#avk47
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game 5
--
Chapters
00:00 Applying Conditional Statements On Lists Stored In Dataframe Cell
01:15 Accepted Answer Score 1
01:33 Thank you
--
Full question
https://stackoverflow.com/questions/7410...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #list #dataframe #booleanlogic
#avk47
ACCEPTED ANSWER
Score 1
You can use the normal > operator and then use agg or apply to get the desired output:
(df > 8000000).apply(list, axis=1)
0 [False, True, False]
1 [False, True, True]
example:
df = pd.DataFrame({'202201': [7180516.0, 4868058.0], '202202': [433433740.0, 452632806.0], '202203': [5444119.0, 10000000.0]})
df['seqToFs'] = (df > 8000000).apply(list, axis=1)