Upgrade from Eikon -> Workspace. Learn about programming differences.

For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
1 1 5 5

Python Time Series - Convert Date Index to Pandas Column

Hi All,


In a simple time series, how do you convert the timestamp, which is in an index to a pandas column formated in dateimte?

eikoneikon-data-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-apitime-series
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thank you for your participation in the forum.
Is the reply below satisfactory in resolving your query?
If yes please click the 'Accept' text next to the reply.
This will guide all community members who have a similar question.
Otherwise please post again offering further insight into your question.
Thanks,
AHS

Please be informed that a reply has been verified as correct in answering the question, and has been marked as such.

Thanks,


AHS


Upvote
Accepted
39.4k 77 11 27

If you have a dataframe named 'df' with DatetimeIndex, the following command will add a column labeled 'Timestamp' and the values corresponding to the values of the index:

df['Timestamp'] = df.index

E.g.

df = ek.get_timeseries('EUR=','CLOSE')
df['Timestamp'] = df.index
df.info()

This returns:

<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 71 entries, 2020-09-28 to 2021-01-04
Data columns (total 2 columns):
 #   Column     Non-Null Count  Dtype         
---  ------     --------------  -----         
 0   CLOSE      71 non-null     float64       
 1   Timestamp  71 non-null     datetime64[ns]
dtypes: datetime64[ns](1), float64(1)
memory usage: 1.7 KB
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

worked for me too. Thank you.
Upvotes
1 0 0 0
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.