use*_*679 2 python datetime pandas
我想+00:00从下面的时间戳中删除 。我使用下面的代码从时间戳中删除了 T 和 Z,但 dtype 仍然是datetime64[ns, UTC] ,理想情况下我想将其转换为 datetime64[ns]
df['Timestamp_column'].dt.tz_localize(None)
Run Code Online (Sandbox Code Playgroud)
转换前的 Timestamp_column:
2020-07-10T14:12:39.000Z
Run Code Online (Sandbox Code Playgroud)
输出:
2020-07-10 14:12:39+00:00
Run Code Online (Sandbox Code Playgroud)
import pandas as pd
df = pd.DataFrame({'Timestamp_column': ['2020-07-10T14:12:39.000Z']})
df['Timestamp_column'] = pd.to_datetime(df['Timestamp_column']).dt.tz_convert(None)
# df['Timestamp_column']
# 0 2020-07-10 14:12:39
# Name: Timestamp_column, dtype: datetime64[ns]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7407 次 |
| 最近记录: |