I have a dataframe called df_output
like so
index col1
0 | ''
1 | ''
2 | ''
3 | ''
4 | ''
If I run df_output['col1'].values.all() == ''
my return value is true
. However if I edit the dataframe so it looks like this
index col1
0 | '324'
1 | ''
2 | ''
3 | ''
4 | ''
And run df_output['col1'].values.all() == ''
I still get a return value of true
. Shouldn't this line return false, since the value at index 0 for col1 is '324'? Or am I misunderstanding how .all() works on a series.
CodePudding user response:
df_output['col1'] == '324'
will give you a per-row comparison with '342'
resulting in a Series of True/False. Then you reduce those True/False into one with (df_output['col1'] == '324').all()
which will be False for both of your example dataframes. However, (df_output['col1'] == '').all()
should give you a True for your first dataframe.