pandas datetime转换为时间戳

Published on Aug. 22, 2023, 12:11 p.m.

```python
df_date = df[‘截止日期’].apply(str)

用to_datetime()函数将字符串转换成时间格式,并增加’时间’字段

df[‘截止日期’] = pd.todatetime(dfdate,format=’%Y-%m-%d’).astype(“int64”)

df[‘截止日期’] = pd.todatetime(dfdate, unit=’s’)

print(df[‘截止日期’])
```

Tags: