79805828

Date: 2025-10-31 13:12:58
Score: 0.5
Natty:
Report link

I know this is from a couple years ago, but I also had this error and found a solution.

In my loop, I did initialize a column with zeros prior to iteratively adding a string to the same column per row in a for loop.

When I initialized my row, I did something like:

df[i].insert(4,"Check",[0]*len(df[i]))

Where i is from another For Loop.

To overwrite the zero within another For Loop and controlled by an if/else statement:

if "something"
    df[i].iloc[j,4] = "Yes"
else
    df[i].iloc[j,4] = "No"

When I ran it, I got the 'Future Warning' error.

To fix it, all I did was make the initialized zero a string by doing:

df[i].insert(4,"Check",["0"]*len(df[i]))

This goes in-line with what others in this thread said, about changing its type.

Since I initialized it as an int, and overwriting it as a str.

But figured I'd throw it here in case it helps anyone in the future.

Thanks.

Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Jon S