This cheat sheet is the most concise Python cheat sheet in the world. It contains keywords, basic data structures, and complex data structures—all in a single 1-page PDF file. If you’re lazy, this cheat sheet is a must! If you love cheat sheets, here are some interesting references for you (lots of more PDF downloads). A detailed Python cheat sheet with key data types, functions, and commands you should learn as a beginner. Free to download as PDF and PNG.
- Statistics cheatsheet
In the Python code importpandasaspd
has been run
Basics¶
Operation | STATA | Pandas | Base R |
---|---|---|---|
Create new dataset from values | |||
Create new dataset from csv file | |||
Print observations | |||
Print observations of variable x | |||
Select only variable x | |||
Select only variables x and y | |||
Drop variable x | |||
Generate new variable | |||
Rename variable | |||
Sort by variable |
Filtering data¶
Operation | STATA | Pandas | Base R |
---|---|---|---|
Conditionally print observations | |||
Conditionally print observations with ‘or’ operator | |||
Conditionally print observations with ‘and’ operator | |||
Print subset of observations based on location | |||
Print observations with missing values in x |
Python Data Science Cheat Sheet
Summarizing data¶
Python Data Analysis Cheat Sheet
Description | STATA | Pandas | Base R |
---|---|---|---|
Print summary statistics | |||
Print information about variables and data types | |||
Print aggregation of variable | |||
Group data by variable and summarize | |||
Print frequency table | |||
Print cross-tabulation | |||
Create bins basedon values in x in new column ‘bins’ |
Reshaping data¶
Operation | STATA | Pandas | Base R |
---|---|---|---|
Reshape data from wide to long panel | |||
Reshape data from long to wide panel |
Python Statistics Cheat Sheet Pdf
Merging data¶
Operation | STATA | Pandas | Base R |
---|---|---|---|
Vertically concatenate datasets | |||
Merge datasets on key |
Python Shapiro Wilk Test
Plotting¶
Python Statistics Cheat Sheet
Operation | STATA | Pandas | Base R |
---|---|---|---|
Scatter plot | |||
Line plot | |||
Histogram | |||
Boxplot |