Datetime from ek.get_timeseries

I have the following python fragment:

sm = ek.get_timeseries(ric, fields='Close', …..

count = sm['CLOSE'].count()

if count >= 1:

for index in range(count):

close_price = sm['CLOSE'][index]

date_time = ...?

I need to save variable date_time="Datetime". How do it.

Best Answer

  • @Peter.Marushchak the timestamp is the pandas dataframe index, you can get the values by accessing it and converting it to the list

    sm.index.tolist()

    The way you are traversing the dataframe is also not quite conventional, I suggest you turn to pandas documentation or code samples. A better way is:

    for index,row in sm.iterrows():
    print(index, row['CLOSE'])