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: http://pandas.pydata.org/pand...
c[c["a"]=="a"]["a"]=100
是我写的不规范么?
import pandas as pd
a=["a","b","a","c"]
b=[1,2,3,4]
a=pd.DataFrame(a)
a.columns=["a"]
b=pd.DataFrame(b)
b.columns=["b"]
c=pd.concat([a,b],axis=1)
print(c)
c[c["a"]=="a"]["a"]=100
print(c)
a b
0 a 1
1 b 2
2 a 3
3 c 4
a b
0 a 1
1 b 2
2 a 3
3 c 4
实际上是Pandas的API改了,在你这行:
改成下面这种形式:
就可以了。