Thanks to antville.org
14 days ago

This is the python way of calculating the date that is 14 days ago.

import datetime
(datetime.datetime.now() - datetime.timedelta(days = 14)).date()

And this is pandas way of getting the same results:

import pandas as pd
(pd.datetime.today() - pd.offsets.Day(14)).floor('D')

... Link (3 comments) ... Comment


Change default head rows from 5 to 3

from functools import partialmethod
pd.DataFrame.head = partialmethod(pd.DataFrame.head, n=3)

... Link (9 comments) ... Comment


Infer types in pandas

This will return the mixed datatypes but this can be slow.

df.applymap(type).nunique() > 1

Better approach pythonic approach would be...

from pandas.api.types import infer_dtype

infer_dtype(df.A)
'mixed-integer'

df.apply(lambda x: 'mixed' in infer_dtype(x))

... Link (5 comments) ... Comment


Python objects and methods

Here are important python objects and their methods
int mul, add, eq, ge, mod, pow
float .isinteger()
string .upper(), .endswith(), .split()
bool .numerator .abs()
list .append, .pop, _len
() / slicing
tuple
dict .items(), .keys(), .values() / slicing
pd.Series .sum(), .stack(), .groupby(), .resample(), .sort_values(), .sort_index(), .iloc
pd.DataFrame

... Link (4 comments) ... Comment


JSON to DF

Here is how to read a JSON file into pandas dataframe.

import json
import pandas as pd

with open('/tmp/aclImdb/movie_data/gv.json', 'r') as f:
data = json.load(f)

df=pd.DataFrame(data['data'])
df.to_excel('gov.xlsx')

... Link (4 comments) ... Comment


Online for 6367 days
Last modified: 1/29/20 11:15 AM
Status
Youre not logged in ... Login
Menu
... Home
... Tags

Search
Calendar
January 2020
SunMonTueWedThuFriSat
1234
567891011
12131415161718
19202122232425
262728293031
December
Recent updates
LibreOffice version conflict I am
not able to install latest version of Libre office. I...
by shantanuo (1/29/20 11:15 AM)
Amazing! Yeahh! you have an
informative blog so far. Thanks for sharing | roof repair...
by Danielperez123 (1/28/20 8:32 PM)
Great Work Thanks for sharing
the post. Microsoft toolkit
by talisasoto1989 (1/27/20 10:22 PM)
Farnham Carpet Cleaning Thanks Farnham
Carpet Cleaning
by Dubs@gl.com (1/27/20 10:13 PM)
Locksmith Guildford That's an interesting
point Locksmith in Guildford
by Dubs@gl.com (1/27/20 10:11 PM)
while loop This is
a sample shell script while loop while read mydb do echo...
by shantanuo (1/26/20 2:24 PM)
compare mysql schema And here
is poor man's schema compare using good old diff command......
by shantanuo (1/26/20 1:49 PM)
Selecting from error log grep
"error" error_log |awk -F[ {'print $4'} \ | sort |...
by shantanuo (1/26/20 12:40 PM)
Rank mysql records using variables
SET @rank = 0, @prev_val = NULL; SELECT rank, correct...
by shantanuo (1/26/20 11:45 AM)
Thanks for sharing this!!
commercial roofing huntsville al
by Mazikeen (1/24/20 6:37 PM)
Sophie Chciałbym więcej o tym
przeczytać. Szybka, jaka literatura ma studiować? texas colleges and universities
by panistefanin (1/24/20 3:45 PM)
Jack Lovely information thank you
very much decanters
by decanter2020 (1/24/20 1:20 PM)
I like it I like
that logic. interior painting
by LisaCook (1/23/20 10:11 PM)
Love it I like this!
Thanks for posting roll off canister
by LaurenHill (1/23/20 10:05 PM)
Thanks for the heads up!
Thank you for sharing this. Our website
by mozaic (1/23/20 2:32 PM)
Thank you for sharing
a really great piece of information. bubble shooter
by longjumper (1/21/20 11:05 AM)
Thanks Thanks for sharing these.
Sam H - Interior Painter Scaumburg Il
by Samh2019 (1/21/20 10:14 AM)
Fencing in Guildford thanks for
the information Fencing in Guildford Fencing in Surrey
by Dubs (1/20/20 9:26 PM)
satta matka matka boss satta
matka Visit our site for more information
by sattamatka3.net (1/20/20 7:52 PM)
Beebeetravvel Thanks for sharing your
valuable information. we are a tour & travel agency with...
by coolexusa (1/20/20 2:27 PM)
Access Control System Dubai Fingerprintdubai
Company is providing many types of Services like , card...
by coolexusa (1/20/20 12:19 PM)
Air Duct Cleaning This type
of Duct cleaning Miami is absolutely not a must have...
by coolexusa (1/20/20 11:26 AM)
Carpet Cleaning Oxford and Surrounding
Areas Interesting read. Carpet cleaning in Oxford and surrounding areas
by Murray Whelehan (1/19/20 8:18 PM)
Antares AutoTune Crack License
Key With Keygen ( MAC ) A Antares AutoTune Pro Crack...
by ijicrackgh (1/19/20 9:50 AM)
Waves Tune Real-Time Crack (Latest)
Free Download 2020! Visit my site and free crack full...
by ijicrackgh (1/19/20 9:45 AM)

RSS feed

Made with Antville
Helma Object Publisher