python - Grabbing selection between specific dates in a DataFrame -


so have large pandas dataframe contains 2 months of information line of info per second. way information deal @ once, want grab specific timeframes. following code grab before february 5th 2012:

sunflower[sunflower['time'] < '2012-02-05'] 

i want equivalent of this:

sunflower['2012-02-01' < sunflower['time'] < '2012-02-05'] 

but not allowed. these 2 lines:

step1 = sunflower[sunflower['time'] < '2012-02-05'] data = step1[step1['time'] > '2012-02-01'] 

but have 20 different dataframes , multitude of times , being able nice. know pandas capable of because if dates index rather column, it's easy do, can't index because dates repeated , therefore receive error:

exception: reindexing valid uniquely valued index objects 

so how go doing this?

you define mask separately:

df = dataframe('a': np.random.randn(100), 'b':np.random.randn(100)}) mask = (df.b > -.5) & (df.b < .5) df_masked = df[mask] 

or in 1 line:

df_masked = df[(df.b > -.5) & (df.b < .5)] 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -