I have a Pandas dataframe that looks like this:
ID Dyn
0 AA01 0.084, 0.049, 0.016, -0.003, 0, 0.025, 0.954, 1
1 BG54 0.216, 0.201, 0.174, 0.175, 0.179, 0.191, 0.200
And I'm looking for a way to iter trough the Dyn column, generating another one that sums only the numbers that are bigger than a cutoff, i.e.: 0.150, assigning all the values that pass it a value of one. This is what the expected result should look like:
ID Dyn Sum
0 AA01 0.084, 0.049, 0.016, -0.003, 0, 0.025, 0.954, 1 2
1 BG54 0.216, 0.201, 0.174, 0.175, 0.179, 0.191, 0.200 7
I thought I could use apply, while ittering trough all of the rows:
for index, rows in df.iterrows():
df['Sum'] = df['Dyn'].apply(lambda x: x = 1 if int(x) > 0.150 )
But I'm lost on how to apply the condition (only sum it if it's greater than 0.150) to all the values inside 'Dyn' and how to assign the value of 1 to them. All advice is accepted. Thanks!