0
votes

When I use the command:

data['DATE_KEY']=pd.to_datetime(data.DATE_KEY)

it returns the timestamp in the format 'yyyy-mm-dd' and I would like it to also return the other content in that timestamp. How do I do this?

The format of the original data is posted the previous question: Bigquery Error When Loading Timestamp

This is the full code that I am using:

data=pd.read_csv('original_data.csv', index_col=False)
data['DATE_KEY']=pd.to_datetime(data.DATE_KEY)
useful_columns = ['DATE_KEY','ITEM_DESCRIPTION','SCAN_UNITS','AVE_UNIT_PRC', 'SCAN_DOLLARS']
data[useful_columns].to_csv('new_data.csv', index=False, sep=",")

This is my resulting file: enter image description here

1

1 Answers

0
votes
time=('9/18/2017 12:00:00 AM')
data=pd.to_datetime(time)
data

ouput:

Timestamp('2017-09-18 00:00:00')

I think the code you write will work,or you may post the data for better debugging.