我正在使用下面的代碼將str('1495596971')轉換爲'%Y-%m-%d%H:%M:%S'但無法爲整列。你能幫我解決嗎?python中的標準日期和時間框架
ho['tweet'] = ho['tweet'].astype(str)
c=ho['tweet']
stddate=c.split('.')[0].split('0')[1]
t=print(
datetime.datetime.fromtimestamp(
int(stddate)
).strftime('%Y-%m-%d %H:%M:%S')
)
其顯示的錯誤: - '系列' 對象有沒有屬性 '分裂'
輸入: -
tweet
0 1495596971.6034188::automotive auto ebc greens...
1 1495596972.330948::new free stock photo of cit...
2 1495596972.775966::ebay: 1974 volkswagen beetl...
3 1495596975.6460807::cars fly off a hidden spee...
4 1495596978.12868::rt @jiikae: guys i think mar...
我只是想 '1495596971', '1495596972' 等這個數據來自列,並希望將其轉換爲標準的日期和時間格式。
嘿,你知道如何獲得所有行的stddate,而不是通過使用c [0]來獲取特定的行。 – Vic13
謝謝@ Tiny.D。它正在工作。 – Vic13
@ Vic13酷,很高興它有助於:) –