pandas


pandas dataframe shift dates


I have a dataframe that is indexed by dates. I'd like to shift just the dates, one business day forward (Monday-Friday), without changing the size or anything else. Is there a simple way to do this?
You can shift with 'B' (I think this requires numpy >= 1.7):
In [11]: rng = pd.to_datetime(['21-11-2013', '22-11-2013'])
In [12]: rng.shift(1, freq='B') # 1 business day
Out[12]:
<class 'pandas.tseries.index.DatetimeIndex'>
[2013-11-22 00:00:00, 2013-11-25 00:00:00]
Length: 2, Freq: None, Timezone: None
On the Series (same on a DataFrame):
In [21]: s = pd.Series([1, 2], index=rng)
In [22]: s
Out[22]:
2013-11-21 1
2013-11-22 2
dtype: int64
In [23]: s.shift(1, freq='B')
Out[23]:
2013-11-22 1
2013-11-25 2
dtype: int64

Related Links

Pandas Dataframe timeseries
Pandas - understanding output of pivot table
Pandas Group By With Running Total
Python pandas json 2D array
rename columns function not working in pandas
Number format column with pandas.DataFrame.to_csv()?
Matplotlib Subplot Labels Disappear
Counting rows between dates in pandas with groupby
Taking second last observed row
retrieve data from pandas dataframe if it doesn't cooccur in previous column
pandas resample MAX-VALUE with corresponding ANGLE-VALUE
Performance issues with writing data to HDFStore
Finding same value index of pandas Series
Get Maximum Value from Dataframe
Slicing in group by function
Grouping factors in python patsy

Categories

HOME
google-chrome-extension
clips
hive
hook
vmware
tizen-web-app
rubygems
binary-tree
umd
acquia
android-youtube-api
phaser
ups
carthage
vaadin7
seaborn
openrefine
ab-testing
oxyplot
textfield
predix
sox
autosys
blazemeter
dxf
vlsi
windows-error-reporting
neo4j-spatial
file-rename
srcset
r-raster
google-cloud-endpoints-v2
ioio
pim
uiswipegesturerecognizer
fusionpbx
dosbox
xenforo
az-application-insights
angularjs-factory
leading-zero
optix
ruby-on-rails-3.1
node-gyp
sencha-touch-2.3
avconv
flickr-api
strptime
pango
promela
clean-architecture
dropbox-php
sybase-asa
capacity
cudafy.net
account-kit
ado.net-entity-data-model
elements
transmitfile
lttng
flash-cs5
suffix-tree
goose
freedesktop.org
pervasive-sql
tcpserver
intellij-14
emailrelay
ionic
skos
inmobi
system.reflection
client-side-templating
phpthumb
picturefill
resty-gwt
balanced-payments
intentservice
commoncrypto
ftps
back-stack
delphi-6
e4x
funscript
stage
mod-auth
table-footer
netbeans-7.1
digest-authentication
getresponsestream
database-management
audio-capture
javap
data-driven
text-coloring
scripting-languages
ugc
3gp

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App