This is probably a very basic question but I can't find the answer in other questions. I have two lists that I have used to create a 2D dataframe, let's say:
X= np.arange(0, 2.01, 0.25)
Y= np.arange(10, 30, 5.0)
df = pd.DataFrame(index = X, columns = Y)
print(df)
Which gives:
10.0 15.0 20.0 25.0
0.00 NaN NaN NaN NaN
0.25 NaN NaN NaN NaN
0.50 NaN NaN NaN NaN
0.75 NaN NaN NaN NaN
1.00 NaN NaN NaN NaN
1.25 NaN NaN NaN NaN
1.50 NaN NaN NaN NaN
1.75 NaN NaN NaN NaN
2.00 NaN NaN NaN NaN
I would like to go through all elements in the dataframe and use the values of X and Y as inputs to some function, foo, that I have written. For example, in the 2rd row, 1st column (using zero indexing) position I have (X, Y) = (0.5, 15.0), so in this position I would like to apply foo(0.5, 15.0) and not foo(2, 1).
I think I should be able to use df.apply() or df.applymap() somehow but I can't figure it out!