python - How to filter shift +/- 1 day in Pandas? -


hi guys suppose have timeseries data. how filter data occurs in 1 days different?

suppose data

date         name 2015-04-03    2015-04-04    2015-04-05    2015-04-03    b 

what want like

df[df.shift(1).contains(df.name) or df.shift(-1).contains(df.name)] 

that give me

date         name 2015-04-03    2015-04-04    2015-04-05    

how in pandas?

you want wrap conditions in parentheses , use bitwise | instead of or:

in [83]: df[(df['name'].shift(1) == df['name']) | (df['name'].shift(-1) == df['name']) ]  out[83]:         date name 0 2015-04-03    1 2015-04-04    2 2015-04-05    

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -