相关疑难解决方法(0)

pandas to_dict with python native datetime type and not timestamp

I have a pandas DataFrame df that contains Timesatamp columns.

I wish to create an iterator of rows (either via the iter.. methods or via to_dict) from df where the Timesatamp values are python datetime.

I have tried doing this

for col in df.select_dtypes(['datetime']):
        df[col] = df[col].dt.to_pydatetime()
Run Code Online (Sandbox Code Playgroud)

however it seems like the columns is still Timesatamp when using the above mentioned iterator methods. Is there a 'batch'y way to achieve this apart from manualy converting each values when …

python timestamp python-datetime pandas

5
推荐指数
1
解决办法
2101
查看次数

标签 统计

pandas ×1

python ×1

python-datetime ×1

timestamp ×1