-1

I'm using pandas 1.5.0, and I'm getting the SettingWithCopyWarning, for the following code:

    df["data"] = df["data"].apply(clip_from_start, args=(16,))
    df = df.dropna()
    df[aug1_col] = df[column].map(augmentor).copy()
    df[aug2_col] = df[column].map(augmentor).copy()

The other reference on this topic: How to deal with SettingWithCopyWarning in Pandas seems to indicate that using .copy should solve the trick. But, it isn't working here.

I also tried:

        df.loc[:, aug1_col] = df[column].apply(augmentor)
        df.loc[:, aug2_col] = df[column].apply(augmentor)

but that didn't work either.

Is the warning in this case just bogus, or is it doing something useful?

Foobar
  • 7,458
  • 16
  • 81
  • 161

1 Answers1

0

Solution was to do:

    df["data"] = df["data"].apply(clip_from_start, args=(16,))
    df = df.dropna()
    df = df.copy()
    df[aug1_col] = df[column].map(augmentor).copy()
    df[aug2_col] = df[column].map(augmentor).copy()
Foobar
  • 7,458
  • 16
  • 81
  • 161