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 can I check if the values in a series are contained in any of the intervals defined the rows of a DataFrame?
MultiIndex and read_table with separate indexes and data
Drop rows of pandas dataframe that don't have finite values in certain variable(s)
concatenate dataframes with different levels of index in pandas
pandas.io.data get_data_yahoo ^DJI retrieval error
“TypeError: only length-1 arrays can be converted to Python scalars”
Pandas resampling hourly timeseries into hourly proportion timeseries
How to customize headers and column widths of DataFrame display?
horizontally centered xlabels for pandas timeseries plotting
drop a single tuple from a multi tuple column
Accessing Row from Previous Day in Pandas Dataframe with Apply
Select a multiple-key cross section from a DataFrame
“Reindexing only valid with uniquely valued Index objects”
How can I divide single values of a dataframe by monthly averages?
How to generate pandas DataFrame column of Categorical from string column?
How to perform key-restricted broadcast-operate-update in Pandas?

Categories

HOME
maven
debugging
keras
mockito
ngrx
plone
raspberry-pi
session
vmware
sd-card
youtube-dl
jira
cross-browser
opengl-es-2.0
swagger-ui
node-notifier
maude-system
export-to-csv
etl
apache-cayenne
messages
uitypeeditor
workload-scheduler
graphlab
contextmenu
tapestry
telerik-reporting
wijmo
icloud-api
rundeck
pepper
facet
semantic-analysis
greendao
maxmind
semantic-versioning
exuberant-ctags
avcapturesession
language-concepts
wpf-controls
disassembling
dartium
webix-treetable
document.write
temporary-files
tasker
android-tabhost
galen
apple-news
google-datalayer
react-scripts
pubmed
multipeer-connectivity
nstextview
brightcove
diagnostics
setuptools
wdf
rotativa
url-masking
trash
nsviewcontroller
pagedlist
system.management
jfugue
thredds
cannon.js
purge
tarjans-algorithm
browser-bugs
php-ci
myo
key-management
clipperlib
apache-commons-net
gulp-less
html-helper
castle
funcunit
pyhdf
access-rights
tidy
apc
quartz-graphics
ruby-datamapper
easy-install
jplaton
e4x
jquery-knob
chuck
bitsharp
broken-links
custom-backend
subscript
zpt
genshi
xtype
calling-convention
locate
android-sdk-2.1
mysql-error-1005
radcombobox
web-application-design
webkit.net
brewmp





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