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 Unmelt dataset
multicollinearity for one-hot encoding
How to work with 'NA' in pandas?
Pandas DataFrame.assign arguments
zipline error KeyError: <type 'zipline.assets._assets.Equity'>
How can i split 'Date' column into 'Date' and 'Time' column? [closed]
Pandas customized group aggregation
What is the significance of t-stats value while applying ttest_ind on two pandas series?
Align order of multiindex dataframe with the order of another multiindex df, pandas
From Object To Date in Pandas [duplicate]
How do I configure PyCharm to Pandas
cannot convert nan to int (but there are no nans)
2 dimension time series groupby in pandas
display the rows based on the last occurrence of an element in a column in Pandas dataframe
How to clip pandas dataframe in place
Pandas get from pandas.core.frame.Pandas object

Categories

HOME
ms-access
cloud
openstack
server
path-finding
bpmn
bookshelf.js
icloud
ckeditor
fingerprint
in-app-purchase
facebook-messenger-bot
windows-10-universal
nano-server
reveal.js
quickbooks
orchardcms
hex-editors
django-admin
ef-migrations
solaris-10
evopdf
nhibernate-envers
nodatime
amazonsellercentral
wkwebview
zurb-foundation-6
linkerd
web-api-testing
typo3-6.2.x
opentype
msys2
libssl
oracle-fusion-middleware
column-family
vsts-build-task
uiswipegesturerecognizer
normal-distribution
picasso
suricata
streamsets
elasticsearch-plugin
ensembles
ruby-on-rails-3.1
node-sass
upstart
powercli
darcs
csound
composite-key
font-size
cudafy.net
medium.com
fputcsv
moveit
ubuntu-10.04
rvest
fadeout
spim
django-unittest
feedback
drawbitmap
php-ci
composite
c3
gadt
nsbutton
html-helper
terminfo
responsive-slides
kgdb
datagridviewcolumn
srs
prettify
ms-project-server-2010
commoncrypto
coverflow
chronoforms
drools-planner
mhtml
libstdc++
dice
word-processor
armcc
jquery-ui-layout
semantic-diff
assembly-loading
custom-backend
adk
fireworks
spyware
appendto
revisions
dbal
ext3
webkit.net
iweb
libs
ubuntu-9.04
.net-1.0
commodore

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