Not able to store timestamp object to csv in pandas

aeapen :

I am trying to write max value of timestamp to csv and its not working.

max_time=status_rank['CREATED'].max()
max_time= pd.DataFrame(max_time)
max_time.to_csv('maxtime_prev_load.csv')

Its giving an error: Data-frame constructor not properly called

DataType

 type(max_time)
    pandas._libs.tslibs.timestamps.Timestamp

Sample data

max_time
Timestamp('2020-03-02 01:41:48')

How to fix this

CameLion :

One way to fix this is using

    pd.DataFrame([max_time]) # or if you need add the column and index, you can try
    pd.DataFrame([max_time], index=['something you like'], columns=['something you like'])

Or following the answer provided by @xxMrPHDxx in the first comment(with small modification), you can do it by

    pd.DataFrame({'Max_time':[max_time]})

The important thing here is to add square brackets.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=32843&siteId=1