pandas


Resample TimedeltaIndex and normalize to frequency


For example, I have got this Series :
17:50:51.050929 5601
17:52:15.429169 5601
17:52:19.538702 5601
17:53:44.776350 5601
17:53:51.870372 5598
17:55:33.952417 5600
17:56:48.736539 5596
17:57:01.205767 5593
17:57:26.066097 5593
17:57:30.644398 5591
I want to resample it but I want that the index start to a rounded frequency.
So in the case above, I want the first index 17:51:00 if I resample on Min frequency.
However Pandas implements it like that :
a.resample('1T', 'mean')
Out[125]:
17:50:51.050929 5601.000000
17:51:51.050929 5601.000000
17:52:51.050929 5601.000000
17:53:51.050929 5598.000000
17:54:51.050929 5600.000000
17:55:51.050929 5596.000000
17:56:51.050929 5592.333333
17:57:51.050929 NaN
How can I have a TimedeltaIndex starting from a rounded index ? Such as Timestamp resampling
A quick way to do it is to normalise the index before resampling (using either floor, ceil, or round):
a.index = a.index.floor(freq='1T')
a = a.resample('1T').mean()

Related Links

pandas groupby (pivot) give the wrong results
No module named 'pandastable'
Large scale pivot table in Python
how to filter by day with pandas
Select non-null rows from a specific column in a DataFrame and take a sub-selection of other columns
Merge and sum Pandas Pivot Table
Counting null as percentage
appending list of lists to pd.Dataframe()
how to perform where and distinct count operation in pandas dataframe?
Pandas Dataframe - Using index as value when slicing/filtering
How can I select out columns where the first values are NaN?
Record limitation in pandas dataframe when importing from a csv file
count of unique values in pandas dataframe column
Rolling sums on pandas dataframe
Pandas Bug - Error when inserting list serialize as string
Formatting index of a pandas table in a plot

Categories

HOME
sendgrid
multithreading
listview
heroku
syntax
bpmn
webstorm
jsp-tags
react-redux
tizen-web-app
rubygems
wamp
flyway4
kentor-authservices
mapserver
export-to-csv
postgres-xl
google-cloud-spanner
phaser
ups
after-effects
ml
java-3d
clickonce
csrf-protection
facebook-instant-articles
facebook-access-token
nhapi
replaceall
opentype
junit5
asset-pipeline
cloud-code
git-merge
objectlistview
sqlite2
ws-security
ncalc
http-live-streaming
ibpy
executenonquery
appcompat
promela
nativeapplication
typed-lambda-calculus
r-forge
pearson
python-cryptography
spring-mongodb
pintos
google-feed-api
ado.net-entity-data-model
skobbler-maps
google-web-starter-kit
etsy
merge-conflict-resolution
qpid
wapiti
kendonumerictextbox
rtbkit
lib.web.mvc
metaclass
comobject
processmodel
ng-animate
nstableviewcell
network-interface
applescript-objc
bitcoinj
castle
project-planning
kgdb
stxxl
access-rights
ora-00911
interface-orientation
distutils
word-processor
automount
newtonscript
jspinclude
regsvr32
deobfuscation
coredump
mysql-error-1005
digest-authentication
coda-slider
gallio
gamequery
suppress
database-management
private-members
ubuntu-9.04

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