将时间戳转换为字符串pandas python

时间:2020-09-25 08:13:31

标签: python-3.x pandas datetime

我已经解析了zip文件

import io
from zipfile import ZipFile
import pandas as pd
def read_zip(zip_fn, extract_fn=None):
    zf = ZipFile(zip_fn)
    if extract_fn:
       return zf.read(extract_fn)
    else:
       return {name:zf.read(name) for name in zf.namelist()}
df = pd.read_excel(io.BytesIO(read_zip(r'C:\download\test.xlsx.zip', 'test.xlsx')))
tuples = [tuple(x) for x in df.values]
print(tuples)

我有数据,该数据打印(元组):

[(Timestamp('2020-01-13 00:00:00'), 'Ivanov', 1985, 'Engineer'), 
(Timestamp('2020-01-14 00:00:00'), 'Smith', 1964, 'Public Agent'), 
(Timestamp('2020-01-15 00:00:00'), 'Pitt', 1977, 'Actor')]

如何将时间戳替换为字符串,如下所示:

[('2020-01-13 00:00:00', 'Ivanov', 1985, 'Engineer'), 
('2020-01-14 00:00:00', 'Smith', 1964, 'Public Agent'), 
('2020-01-15 00:00:00', 'Pitt', 1977, 'Actor')]

0 个答案:

没有答案