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

Remove elements of one list from another list using “while”
Hosting Bokeh Server with Tornado on AWS
Functions that help to understand json(dict) structure
Scapy How converting hex to new packet
Write and read test files in dictionary format
Python 3.x Connect to account with request POST
AttributeError: module 'networkx' has no attribute 'Graph'
How to exclude selected domains from python crawl script in google search
Python - Py2exe error
Anaconda import packages from another environment
How to Drag & Drop Multiple rows of a QTableView in pyqt5
Handle prompts in Python - popen
How to create an infinite iterator to generate an incrementing alphabet pattern?
Python RTMP Authenticiation Script
How to change background colour in Kivy
Is it correct to use kwargs in the following scenario of python code?

Categories

HOME
symfony
numpy
pug
admin-on-rest
textwatcher
backup
puppet
playframework
ubuntu-12.04
rfc
ios10
xtext
httpclient
sudo
flexbox
ssr
rebol2
sendkeys
rhapsody
jive
pycrypto
scalaz7
avplayeritem
fabric
jflex
hash-collision
rhandsontable
cep
mef2
metadata-extractor
multichoiceitems
cell-array
superscript
graph-databases
powershell-remoting
mmdrawercontroller
es-shell
android-download-manager
haskell-pipes
silverlight-3.0
rule
wcf-security
xbim
automator
vcf
chown
drawingarea
jags
broadcast
jenkins-jira-trigger
shutdown
photon-controller
fedora20
gce
cdk
pycurl
uicollectionviewlayout
opencpu
teiid
communication-protocol
rxvt
gradle-script-kotlin
hspec
easing
pax-web
qregexp
com-interop
listadapter
clob
string-parsing
faraday
logcat
xmp
handlebars.java
cmocka
throughput
js-cookie
type-mismatch
criteria-api
web-component-tester
ember-cli-addons
adodb
ejabberd-saas
django-1.6
scala-2.11
funkload
mbox
reserved-words
chrome-for-android
gfs
goinstant
javascriptmvc
attachevent
pitch
static-variables
plone-funnelweb
redirectstandardoutput
nemerle
coff
windows-live-id
zend-form-element
libavformat
chatroom
asp.net-routing
querypath
delegatecommand
graniteds
visual-c++-2008-express
pci-bus
multibyte-functions
openwysiwyg
visual-studio-dbpro

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