python - How to access first and last timestamp in dataframe -


i need have string of first , last timestamp (i'm using them index) in dataframe use later. searched on internet, couldn't find it.

this how read .csv file

with open(filename, 'r') csvfile:         df = pandas.read_csv(csvfile,                  parse_dates=true,                  index_col=0,                  sep=';',                  skipinitialspace=true,                  low_memory=false,                  names=range(0,n)) 

i tried using df.iloc[0], couldn't right. how can timestamps (as strings)?

example csv:

                       1    2 2015-07-02 21:40:00 -2.7 -2.7 2015-07-02 21:50:00 -2.5 -2.5 2015-07-02 22:00:00 -2.5 -2.5 

i'm trying first (2015-07-02 21:40:00) , last (2015-07-02 22:00:00) timestamp.

what kind of string want?

df.index.min() df.index.max() 

gets like

in [8]: df.index.min() out[8]: timestamp('2000-01-01 00:00:00') 

dont know if there flag output. personally, - stupid - hardcoded stuff like

maxi_date1 = str(df.index.max()) maxi_date = maxi_date1[0:10] 

to example yyyy-mm-dd.


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -