The Beginner’s Python Cheatsheet!
This is a reference list of basic Python code, mostly in the context of Data Science.
Also available on Github if you want to fork the repo!
Where I’ve put in links, these guys have already done a great job of it, so I’ll leave it to the experts - just click into it!
Most of this will be quite basic, likely most valuable for beginner individuals just doing a quick Google to figure something out. This list is not meant to be exhaustive, just sufficient for basic purposes.
Standard terms used below - replace with your own:
- df for dataframes
- file for filenames
- database for databases
I use quite a fair bit of pandas (it’s a library for the uninitiated), just because it is so much more efficient and straightforward.
This is very much still a work in progress so do pardon the messiness for now. I am also just still learning so if there are any areas of improvement, please do share.
- Importing data from a file (CSV, Excel or JSON)
- Connecting to servers such as MSSQL
- Importing/scraping finance data, tables or text from the web (datareader/BeautifulSoup)
- Importing data from APIs
- Exploring the data structure
- Data selection
- Numerical data exploration
- Categorical data exploration
- Changing data structure
- Changing data type
- Some useful snippets of code
- General code
- Using matplotlib
- Using seaborn
- Using Pandas
- Using Plotly
- Random formats for reference, or useful or interesting tips that I find helpful/speeds things up!
Edit: 19 August 2020
So the folks at Toptal (a company that helps to connect companies with talent) have come up with an hiring guide for python here: https://www.toptal.com/python#hiring-guide
I think it provides some helpful tips and interesting perspectives on how different people view/use python so it is worth a read (for any python user, be it hiring managers or applicants)!
just keep in mind that people are entitled to their own opinions and you don’t necessarily have to agree with theirs! (like, i think pytest has a pretty big following too, compared to unittest for unit testing?)