python-3.x - 使用 pandas 从 Excel 工作表中的列中提取数据
问题描述
在我的 Excel 表中有一个类型为“InvoiceDate”的列datetime64
。我正在尝试从此列中提取日期并为其分配一个新列。
下面是我的 python 代码以及数据表的图像。它输出警告,但操作已成功完成。
代码:
df1["InvoiceMonth"] = df1["InvoiceDate"].dt.date
错误:
C:\Users\anaconda3\lib\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
解决方案
推荐阅读
- reactjs - 面包屑反应代码不起作用,我该如何解决?
- haskell - 如何将 `throwM` 与 `Except` 一起使用?
- bazel - 带有 protobuf / gRPC-gateway / golang 的 bazel - 入门
- angular - 将带有 rxjs 的 Angular 5 模块导入 Angular 8 应用程序
- ios - Firebase Firestore collectionGroup()查询方法无法识别 - swift
- acumatica - 如何在报表设计器中通过 URL 引用外部图像?
- php - MySQL阻止用户从其他用户那里获取代码
- excel - 在单元格中搜索特定文本并从列表中返回匹配的文本
- kotlin - Kotlin 结合使用箭头、lamda、?、. , 然后让。什么意思?
- python - Pandas to_sql 设置列类型