【发布时间】:2021-12-14 23:04:34
【问题描述】:
我有以下代码:
#converts SQLite data to a Panda data frame
df1 = pd.read_sql_query("SELECT * FROM Accounts", conn)
df2 = pd.read_sql_query("SELECT * FROM Rates", conn)
df3 = pd.read_sql_query("SELECT * FROM Clients", conn)
#Create new data frame as working space
dfnew= df1[['Client','Product','CCY','Balance']]
#map Currency code
dfnew['fxrate'] = dfnew.CCY.map(df2.set_index('Currency code')['Rate'])
dfnew.head()
当我运行结果时,输出符合预期。但是我收到以下消息:
C:\ProgramData\Anaconda3\lib\site-packages\ipykernel_launcher.py:14: 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/pandas-docs/stable/indexing.html#indexing-view-versus-copy
这是什么意思? 我的代码有问题吗?
【问题讨论】: