python


String formatting of timedeltas in Pandas


I noticed that Pandas knows how to smartly format a timedelta object into a string.
In [1]: df[column][rows].max()
Out[1]:
0 2 days, 02:08:07
dtype: timedelta64[ns]
When I try to do this manually I keep getting the string in nanoseconds.
In [2]: df[column][rows].max()[0]
Out[2]: numpy.timedelta64(180487000000000,'ns')
In [2]: str(df[column][rows].max()[0])
Out[2]: '180487000000000 nanoseconds'
I would rather not reinvent the wheel, so is there any way to access the string formatting method (or the string itself) that Pandas uses to show a timedelta object in x days, hh:mm:ss ?
The function is located here:
pd.tslib.repr_timedelta64
In action:
In [11]: pd.tslib.repr_timedelta64(np.timedelta64(180487000000000,'ns'))
Out[11]: '2 days, 02:08:07'

Related Links

Multiple foreign key fields in abstract Django class
How to convert the value_list to list in Django
Implicit Differentiation Sympy
Why does pygame stop working when I remove a print statement?
Interact with an interactive shell script on python
Need help connecting to SQL Server from Python Flask-Appbuilder
pyspark : Convert DataFrame to RDD[string]
Docker and single python file
Passing user inputs directly in python
Django Generic Foreign Key Sorting
Python prime listing repetition bug
Summing values of a pandas data frame given a list of columns [duplicate]
Why is the top level package being removed? Python
List of objects function not working
multiple assignments in one line for loop python
selenium unicode encode error

Categories

HOME
spring
crystal-reports
cil
sidekiq
ssas-2012
pug
paramiko
boost-thread
angular2-routing
wms
actionscript
codeeffects
phaser-framework
value
user
lotus-notes
packer
jboss7.x
uiview
squarespace
jacoco
pdo
eclipse-luna
ada
raphael
nmake
uiautomator
fop
jquery-form-validator
hhvm
csh
tfs2013
superagent
backup-strategies
pycparser
ocs
gettext
mms
elfinder
equivalence
jrules
openweathermap
timesten
nstouchbar
ti-basic
gauss
webdatagrid
applepayjs
tiddlywiki
windows-95
volume
photography
search-box
rsqlite
sql-import-wizard
pdflib
aescryptoserviceprovider
linkageerror
mongo-c-driver
xmp
web-essentials
self-hosting
java.util.calendar
eyeql
integral
viper-architecture
criteria-api
isml
consensus
ejabberd-saas
orientation-changes
rhel5
gmaps4rails
kendo-mvvm
and-operator
mov
facebook-wall
ember-addon
aquafold
alpha-transparency
spdy
visual-c++-2010-express
visual-studio-addins
arangodb-php
sanitization
confusion-matrix
image-zoom
localtime
backbone-relational
justgage
grunt-contrib-compass
phpsh
mvccontrib
sunspot-rails
unions
isolatedstorage
v4l
emacs23
fileutils
for-xml-path
getresource
delegatecommand
winverifytrust
asp.net-mvc-controller
economics

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