python - 在 Pandas 中进行日期时间对话时获取“SettingWithCopyWarning”
问题描述
我正在尝试将日期时间字段转换为熊猫中的日期。
我的代码
final_result['DATE_TO'] = pd.to_datetime(final_result['DATE_TO'], utc=True, dayfirst=True).dt.date
来自 Python 的警告消息
/opt/app-root/lib/python3.6/site-packages/ipykernel_launcher.py:1: 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
样本数据
final_result['DATE_TO_']
0 2020-01-26 10:07:02
1 2019-11-27 06:12:12
2 2019-12-11 08:00:08
3 2019-12-05 11:20:03
4 2019-12-07 04:50:10
如何解决这个问题。
解决方案
推荐阅读
- javascript - 使用 addClass() 定位结构中的元素
- python - pytesseract:良好的 OCR 或良好的线条 - 绝不会两者兼而有之
- javascript - 使用占位符信息正确构造数组,直到填充所选对象
- fetch - 如何在继续欢迎意图之前等待此 fetch JSON 请求
命令 - javascript - 在 Jquery 中创建图表时选择的 rangeSelector 不起作用
- javascript - 我的 javascript 循环/while 语句代码不起作用,请帮我确定我的问题
- c - 理解 C99 中的这个“外部内联”调用
- asp.net-core - 包括客户端证书和身份用户在内的多种认证方案
- spring - Spring-Data-Jpa 按特定值按关系实体查找所有内容
- asp.net-mvc - Vue.Js - 如何从 MVC 视图模型将数据加载到 Vue 实例中?