2017-02-08 18 views
0

私は、次のコードを持っている:rowがパンダデータフレーム列であるパンダ:タイムスタンプ変換タイプエラー

import datatime as dt 

print(type(row['my_timestamp'])) 
current_date = dt.date.fromtimestamp(row['my_timestamp']) 

しかし、次の出力とエラーました:

<class 'pandas.tslib.Timestamp'> 
--------------------------------------------------------------------------- 
TypeError         Traceback (most recent call last) 
<ipython-input-44-95348c1ae55f> in <module>() 
    10  print(type(row['my_timestamp'])) 
---> 11  current_date = dt.date.fromtimestamp(row['my_timestamp']) 

TypeError: an integer is required (got type Timestamp) 

私が見逃しているかもしれないものの任意のアイデアを?ありがとう!

答えて

1

fromtimestampは、エポックタイムを秒単位で整数として想定しています。 pandasは既にdatetime.dateタイプを出力する方法.dateを持っています。

current_date = row['my_timestamp'].date() 
関連する問題