I have a dataframe df that has thousands of rows.
For each row I want to apply function func.
As a test, I wanted to run func for only the first row of df. In func()
I placed a print statement. I realized that the print statement was run 2 times even though I am slicing df to one row (there is an additional row for columns but those are columns).
When I do the following
df[0:1].apply(func, axis=1, x,y,z)
or
df.iloc[0:1,:].apply(func, axis=1, x,y,z)
The print statement is run 2 times, which means func()
was executed twice.
Any idea why this is happening?