I have a panda dataframe form CSV file with the following index
Time stamp SOG Height 2015-03-11T08: 49: 53.000Z 0 20 2015-03-11T08: 49: 42.000Z 0 19 2015-03-11T08: 49: 32.000Z 0 24 .....
I would like to use ix to break the dataframe but I have to enter the index only hours and minutes, not true value.
For example
df3 = df.ix ['2015-03-11T08: 49': '2015-03-11T08: 52', ['SOG' , 'Height']]
Should I use regular passengers or is there a way for pandas to do this?
If you time stamp
a DatetimeIndex, you can use it :
import io import pandas as pd text = '' '\ timestamp SOG altitudes 2015-03-11T08: 49: 53.000Z 0 20 2015-03-11T08: 49: 42.000 J. 1 9 2015-03-11 Tate 8: 49: 32 degree 0 24 '' 'df = pd.read_table (io.BytesIO (text), sep =' \ s {2,} ') df [' Time stamp '] = pd.to_datetime (df [' time stamp ']) df = df.set_index ([' time stamp ']) df.between_time (' 8:49:32 ',' 8:49:52 ')
yields
SOG Altitude Time Stamp 2015-03-11 08:49:42 0 19 2015-03-11 08:49:32 0 24
No comments:
Post a Comment