0% found this document useful (0 votes)
15 views1 page

Lasse1618 Python-Pandas

Uploaded by

Bráulio Cruz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views1 page

Lasse1618 Python-Pandas

Uploaded by

Bráulio Cruz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python Pandas Cheat Sheet

by LasseBoe (Lasse1618) via cheatography.com/110079/cs/21581/

STOPPED FILLING AT LECTURE 6 LINE Basic Dataframe Analysis (cont) Label-​based indexing with .loc / .iloc
122 (cont)
df.plo​t.s​cat​‐ scatte​rplot
ter(x = df.loc[:, 'col1' ] column with t/f whether
'name', y = == 'name' entry in col1 is name
Basics 'name')
%matpl​otlib inline plots into notebook pd.plo​tti​‐ multiple scatte​rplots df.ilo​c[3:-1, 2:] [rows, columns]
df = pd.rea​d_c​‐ loads dataframe ng.s​ca​tte​‐ df.iloc[:, [3, 1]] columns with index 3 & 1
sv(​ path, r_m​atr​ix(df)
.loc is label based, .iloc is integer index
index_col pd.plo​tti​‐ lines drawn connecting
based
='name') ng.p​ar​all​‐ dimensions of an entry
df.head() el_​coo​rdi​‐
Series
nat​es(df,
df.tail()
'name') s1 = pd.Ser​ies([1, 2, creates a pandas
df.values 3], index=​['a', 'b', series
df['co​l_n​‐ returns list of singled entries
df.plot() 'c'])
ame​'].u​‐
df.plot(style='.') s1.add(s2, fill_v​alue=0)
nique
df.index returns row indexes s.isnull() ; s.notn​ull()
pd.get​_du​‐ dummie column (0 or 1) that
df[co​l].lo​c[ ​index] returns value with mmi​es(df, indicates whether the entry s.dropna() drops all rows with
given column and column​s= in another column is a missing values
index [​'Na​me']) certain entry s.fill​na(x)
df.loc[:, 'col_n+1'] referring to a col that np.ran​‐ selects random set s = pd.Dat​aFr​ame​‐ Best way to define
=x doesn't exist creates a dom.ch​‐ ({'​Siz​e':s1, 'Weigh​‐ dataframe out of
new one oice(n, x, t':s2}) series:
replac​e=f​‐ Give dict out of
Basic Dataframe Analysis alse) columns
df.isn​ull() returns bool np.set​dif​‐ New set with only the 'e' in s1 returns bool
df[.is​nul​l().sum returns sum of trues f1d​(set_1, differing entries
s.name = 'str' names series
set_2)
df.isn​ull​().any checks whether there is s.inde​x.name = 'str' names index
a true df.to_​‐ gives array of entries
If s doesn't exist, this
numpy()
df[col].max() creates a df
df[col].min() s.colu​mns​['Red', 'Green']
Working with a Dataframe
df[col].idxmax() s.columns.name = 'Color'
df['c​ol1'] == x bool if entry is x
df[col].idxmin() s.rein​dex​[('m', 'n', ffill = forward fill
df[df == x] = y replace all values of a kind 'o'], method = 'ffill')
df[c​ol​].​med​ian()

df[c​ol​].​mean() Label-​based indexing with .loc / .iloc


df[c​ol​].​des​‐ gives statistic analysis
df.loc​[r​owi​ndex, colum​nname]
cribe()
df.loc[3, col1] 3rd entry of 1st
df[c​ol​].​qua​‐ 50% quantile df.loc[3:6, ['col1', column
nti​le(.5) 'col2']]
df.box​plot(by = boxplot grouped by
'col') column
df.his​t(bins = 20) histogram in 20 bars

By LasseBoe (Lasse1618) Not published yet. Sponsored by ApolloPad.com


cheatography.com/lasse1618/ Last updated 23rd November, 2020. Everyone has a novel in them. Finish
Page 1 of 1. Yours!
https://apollopad.com

You might also like