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

Iterate function changing parameter after each run
How to access name of a specific vertex in graph (python-igraph)
gdal_merge overlaying pngs over one another
How would I use a attribute or a element that will split my data from adding with each other
Scraping HTML forms with regex
How to reduce time complexity of a program for finding length of a factorial in python?
Python socket programming-saving data from socket
Python3 find last occurrence string then write
python method works outside of Class, but not within Class
How do I optimize this python code using cython?
Python - regex lookup for multiple lines of HTML
Python: how to omit lines in a .txt file
Creating COM object via ssh (issue with AutoCAD.Application)
Python: Nested While Loops & Continue Looping
Why is the group method allowed on re.match even though it can sometimes return None?
How to decode list of urls in file

Categories

HOME
reverse-engineering
bing
angular2-directives
survival-analysis
csvhelper
ext.net
contact-form-7
unity2d
keystore
cartodb
iso
camera-calibration
uiscrollview
nuxt.js
phoenix
cairo
clover
autolayout
hhvm
bcrypt
tflearn
yosys
continuous-deployment
version-numbering
ivy
strophe
shapes
recurrence-relation
shibboleth
rider
es-shell
tic-tac-toe
infusionsoft
twiki
sendgrid-templates
jupyter-console
tripwire
google-account
android-maps-v2
rkt
gd
amazon-machine-learning
gist
rhel6
dwarf
component-pascal
chrome-remote-desktop
visual-studio-templates
festival
pspice
verbose
cfeclipse
proxygen
handlebars.java
servlet-3.0
loose-typing
sonarqube5.3
ninject.web.mvc
lmfit
mysqldumpslow
paypal-nvp
visual-studio-code
pyrocms
lines-of-code
callstack
cocoascript
errorprovider
jstat
code-testing
neoload
kraken.js
bounds
initialization-vector
ksoap2
winrt-httpclient
hamsterdb
bsod
jquery-tabs
convex-polygon
entity-framework-4.1
nuspec
resgen
digital-design
graph-coloring
sequelpro
mvccontrib
autostart
static-variables
redirectstandardoutput
querystringparameter
shared-objects
surf
ets
server-error
nvelocity
email-spec
requestfactory
unreachable-code
mvvm-foundation
multibyte-functions
project-lifecycle
dotproject

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