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

How to assign a Series to a DataFrame from a Panel?
is there a bug in pandas DataFrame corrwith function?
How to subtract a Series from a DataFrame while keeping the DataFrame struct intact?
Zipline data msgpacks aren't distributed with source -algo trading
HDFStore Term memory efficient way to check for membership in list
Why equal variables are compared in Pandas Cython code?
Display multiple output tables in IPython notebook using Pandas
How to reset a pandas dataframe data types to default or auto detect?
How to add a column to all DataFrames inside a Panel (don't mind using a for loop)
What is the functionality of the filling method when reindexing?
Pandas, multiindex, dates, HDFstore and frame_tables
Binary operation broadcasting across multiindex
Insert or replace like operation for Pandas HDFStore (table)
Parsing excel files with Pandas
grouping by column and then doing a boxplot by the index in pandas
How to create a lagged data structure using pandas dataframe

Categories

HOME
hook
activiti
push-notification
appx
iterator
cmd
cakephp-2.5
packages
angular-ui-bootstrap
ebean
serverspec
onelogin
qore
add
adfs
virtualization
applepay
session-variables
quickbooks
zend-framework3
carthage
quartz-scheduler
caml
dosgi
connection-string
introduction
nas
kryo
chromium-embedded
rundeck
angular2-aot
tdd
fabric8
galsim
atl
appfabric
devextreme
angularjs-factory
lumberjack
squib
avro4s
ibpy
spring-security-kerberos
modelmapper
auto-update
menuitem
rails-routing
boost-multi-index
brightcove
nativeapplication
nodebb
namecoin
epson
spring-mongodb
pintos
watchconnectivity
word-vba-mac
parallel-data-warehouse
libpng
azure-virtual-network
intrusion-detection
thrust
persist
uid
splash
sysinternals
method-parameters
proj4js
truevault
c++03
bigbluebutton
offloading
asp.net-web-api-odata
responsive-slides
jubula
htmlcleaner
braille
coverflow
opcache
flash-builder4.5
file-locking
ora-00911
buster.js
mylyn
selected
mhtml
jquery-knob
unc
google-email-migration
dice
first-responder
appconkit
nsmanagedobject
removeclass
boost-filesystem
xdomainrequest
propagation
datareader
lang
radcombobox
.nettiers
gamma
modelstate
routedevent
perfect-hash
database-management
libs
microsoft-virtualization
zune
ugc
django-notification
document-conversion

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