when i use
df['b'] = df['a'].str.split("_").str.get(0)
i got
D:ProgramFilesanaconda3Libsite-packagesgeopandasgeodataframe.py:1543: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
super().__setitem__(key, value)
What should I do to cancel the warning without using pd.options.mode.copy_on_write = True
?
GeoPandas.__version__
is 0.14.2
i tried
df.loc[:,'b'] = df['a'].str.split("_").str.get(0)
or
df.loc[:,'b'] = df.loc[:,'a'].str.split("_").str.get(0)
the warning still exists
New contributor
shuoren fei is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.