小编mrk*_*goh的帖子

Pandas.to_datetime() 尝试在 DataFrame 的切片副本上设置一个值

我还没有收到其他功能的复制警告,并且我还没有找到解决它的方法。

这是我的代码:

div_df.loc[:,"Ann.Date"] = pd.to_datetime(div_df.loc[:,"Ann.Date"], format='%d %b %Y')

/volume1/homes/id/venv/lib/python3.8/site-packages/pandas/core/indexing.py:1843: 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
  self.obj[item_labels[indexer[info_axis]]] = value
Run Code Online (Sandbox Code Playgroud)

除了以下之外,我还没有找到其他解决方案:

div_df.loc[:,"Ann.Date"] = pd.to_datetime(div_df.loc[:,"Ann.Date"], format='%d %b %Y', errors='coerce')
Run Code Online (Sandbox Code Playgroud)

python python-3.x pandas

2
推荐指数
1
解决办法
3350
查看次数

标签 统计

pandas ×1

python ×1

python-3.x ×1