I have come across this problem several times. The problem is that I cannot understand how to iterate through a pandas series in a DataFrame to access individual values.
In this particular case I am trying to find the maximum value for each row in a specific column in a pandas DataFrame, some rows of which contain lists.
df
is as such:
Date Number
0 2000-01-01 [1.0]
1 2000-01-02 [2.2, 5, 7.8]
2 2000-01-03 [8.2]
3 2000-01-04 [4, 11.78, 24.66]
The attempted code has been the following in relation to this question:
Find the max of two or more columns with pandas
However I am trying to replace the current column and for some reason it seems to provide my column with an empty list.
Desired output would be the following:
Date Number
0 2000-01-01 1.0
1 2000-01-02 7.8
2 2000-01-03 8.2
3 2000-01-04 24.66
Taking the max of the row and replacing the original. Any suggestions as to how to do this?
Thanks in advance.