Python for Data Analytics - Quick Cheatsheet with Cod e Example 🚀
1️⃣ Data Manipulation with Pandas
2️⃣ Numerical Operations with NumPy
3️⃣ Data Visualization with Matplotlib & Seaborn
4️⃣ Exploratory Data Analysis (EDA)
5️⃣ Working with Databases (SQL + Python)
React with ❤️ for more
Share with credits: https://news.1rj.ru/str/sqlspecialist
Hope it helps :)
1️⃣ Data Manipulation with Pandas
import pandas as pd
df = pd.read_csv("data.csv")
df.to_excel("output.xlsx")
df.head()
df.info()
df.describe()
df[df["sales"] > 1000]
df[["name", "price"]]
df.fillna(0, inplace=True)
df.dropna(inplace=True)
2️⃣ Numerical Operations with NumPy
import numpy as np
arr = np.array([1, 2, 3, 4])
print(arr.shape)
np.mean(arr)
np.median(arr)
np.std(arr)
3️⃣ Data Visualization with Matplotlib & Seaborn
import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4], [10, 20, 30, 40])
plt.bar(["A", "B", "C"], [5, 15, 25])
plt.show()
import seaborn as sns
sns.heatmap(df.corr(), annot=True)
sns.boxplot(x="category", y="sales", data=df)
plt.show()
4️⃣ Exploratory Data Analysis (EDA)
df.isnull().sum()
df.corr()
sns.histplot(df["sales"], bins=30)
sns.boxplot(y=df["price"])
5️⃣ Working with Databases (SQL + Python)
import sqlite3
conn = sqlite3.connect("database.db")
df = pd.read_sql("SELECT * FROM sales", conn)
conn.close()
cursor = conn.cursor()
cursor.execute("SELECT AVG(price) FROM products")
result = cursor.fetchone()
print(result)
React with ❤️ for more
Share with credits: https://news.1rj.ru/str/sqlspecialist
Hope it helps :)
❤10👍9
10 Ways to Speed Up Your Python Code
1. List Comprehensions
numbers = [x**2 for x in range(100000) if x % 2 == 0]
instead of
numbers = []
for x in range(100000):
if x % 2 == 0:
numbers.append(x**2)
2. Use the Built-In Functions
Many of Python’s built-in functions are written in C, which makes them much faster than a pure python solution.
3. Function Calls Are Expensive
Function calls are expensive in Python. While it is often good practice to separate code into functions, there are times where you should be cautious about calling functions from inside of a loop. It is better to iterate inside a function than to iterate and call a function each iteration.
4. Lazy Module Importing
If you want to use the time.sleep() function in your code, you don't necessarily need to import the entire time package. Instead, you can just do from time import sleep and avoid the overhead of loading basically everything.
5. Take Advantage of Numpy
Numpy is a highly optimized library built with C. It is almost always faster to offload complex math to Numpy rather than relying on the Python interpreter.
6. Try Multiprocessing
Multiprocessing can bring large performance increases to a Python noscript, but it can be difficult to implement properly compared to other methods mentioned in this post.
7. Be Careful with Bulky Libraries
One of the advantages Python has over other programming languages is the rich selection of third-party libraries available to developers. But, what we may not always consider is the size of the library we are using as a dependency, which could actually decrease the performance of your Python code.
8. Avoid Global Variables
Python is slightly faster at retrieving local variables than global ones. It is simply best to avoid global variables when possible.
9. Try Multiple Solutions
Being able to solve a problem in multiple ways is nice. But, there is often a solution that is faster than the rest and sometimes it comes down to just using a different method or data structure.
10. Think About Your Data Structures
Searching a dictionary or set is insanely fast, but lists take time proportional to the length of the list. However, sets and dictionaries do not maintain order. If you care about the order of your data, you can’t make use of dictionaries or sets.
1. List Comprehensions
numbers = [x**2 for x in range(100000) if x % 2 == 0]
instead of
numbers = []
for x in range(100000):
if x % 2 == 0:
numbers.append(x**2)
2. Use the Built-In Functions
Many of Python’s built-in functions are written in C, which makes them much faster than a pure python solution.
3. Function Calls Are Expensive
Function calls are expensive in Python. While it is often good practice to separate code into functions, there are times where you should be cautious about calling functions from inside of a loop. It is better to iterate inside a function than to iterate and call a function each iteration.
4. Lazy Module Importing
If you want to use the time.sleep() function in your code, you don't necessarily need to import the entire time package. Instead, you can just do from time import sleep and avoid the overhead of loading basically everything.
5. Take Advantage of Numpy
Numpy is a highly optimized library built with C. It is almost always faster to offload complex math to Numpy rather than relying on the Python interpreter.
6. Try Multiprocessing
Multiprocessing can bring large performance increases to a Python noscript, but it can be difficult to implement properly compared to other methods mentioned in this post.
7. Be Careful with Bulky Libraries
One of the advantages Python has over other programming languages is the rich selection of third-party libraries available to developers. But, what we may not always consider is the size of the library we are using as a dependency, which could actually decrease the performance of your Python code.
8. Avoid Global Variables
Python is slightly faster at retrieving local variables than global ones. It is simply best to avoid global variables when possible.
9. Try Multiple Solutions
Being able to solve a problem in multiple ways is nice. But, there is often a solution that is faster than the rest and sometimes it comes down to just using a different method or data structure.
10. Think About Your Data Structures
Searching a dictionary or set is insanely fast, but lists take time proportional to the length of the list. However, sets and dictionaries do not maintain order. If you care about the order of your data, you can’t make use of dictionaries or sets.
👍4❤3
5 Free Python Courses for Data Science Beginners
1️⃣ Python for Beginners – freeCodeCamp
2️⃣ Python – Kaggle
3️⃣ Python Mini-Projects – freeCodeCamp
4️⃣ Python Tutorial – W3Schools
5️⃣ oops with Python- freeCodeCamp
1️⃣ Python for Beginners – freeCodeCamp
2️⃣ Python – Kaggle
3️⃣ Python Mini-Projects – freeCodeCamp
4️⃣ Python Tutorial – W3Schools
5️⃣ oops with Python- freeCodeCamp
👍10
I have curated the list of best WhatsApp channels to learn coding & data science for FREE
Free Courses with Certificate: Free Courses With Certificate | WhatsApp Channel (https://whatsapp.com/channel/0029Vamhzk5JENy1Zg9KmO2g)
Jobs & Internship Opportunities:
https://whatsapp.com/channel/0029VaI5CV93AzNUiZ5Tt226
Web Development: Web Development | WhatsApp Channel (https://whatsapp.com/channel/0029VaiSdWu4NVis9yNEE72z)
Python Free Books & Projects: Python Programming | WhatsApp Channel (https://whatsapp.com/channel/0029VaiM08SDuMRaGKd9Wv0L)
Java Resources: Java Coding | WhatsApp Channel (https://whatsapp.com/channel/0029VamdH5mHAdNMHMSBwg1s)
Coding Interviews: Coding Interview | WhatsApp Channel (https://whatsapp.com/channel/0029VammZijATRSlLxywEC3X)
SQL: SQL For Data Analysis | WhatsApp Channel (https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v)
Power BI: Power BI | WhatsApp Channel (https://whatsapp.com/channel/0029Vai1xKf1dAvuk6s1v22c)
Programming Free Resources: Programming Resources | WhatsApp Channel (https://whatsapp.com/channel/0029VahiFZQ4o7qN54LTzB17)
Data Science Projects: Data Science Projects | WhatsApp Channel (https://whatsapp.com/channel/0029Va4QUHa6rsQjhITHK82y)
Learn Data Science & Machine Learning: Data Science and Machine Learning | WhatsApp Channel (https://whatsapp.com/channel/0029Va8v3eo1NCrQfGMseL2D)
ENJOY LEARNING 👍👍
Free Courses with Certificate: Free Courses With Certificate | WhatsApp Channel (https://whatsapp.com/channel/0029Vamhzk5JENy1Zg9KmO2g)
Jobs & Internship Opportunities:
https://whatsapp.com/channel/0029VaI5CV93AzNUiZ5Tt226
Web Development: Web Development | WhatsApp Channel (https://whatsapp.com/channel/0029VaiSdWu4NVis9yNEE72z)
Python Free Books & Projects: Python Programming | WhatsApp Channel (https://whatsapp.com/channel/0029VaiM08SDuMRaGKd9Wv0L)
Java Resources: Java Coding | WhatsApp Channel (https://whatsapp.com/channel/0029VamdH5mHAdNMHMSBwg1s)
Coding Interviews: Coding Interview | WhatsApp Channel (https://whatsapp.com/channel/0029VammZijATRSlLxywEC3X)
SQL: SQL For Data Analysis | WhatsApp Channel (https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v)
Power BI: Power BI | WhatsApp Channel (https://whatsapp.com/channel/0029Vai1xKf1dAvuk6s1v22c)
Programming Free Resources: Programming Resources | WhatsApp Channel (https://whatsapp.com/channel/0029VahiFZQ4o7qN54LTzB17)
Data Science Projects: Data Science Projects | WhatsApp Channel (https://whatsapp.com/channel/0029Va4QUHa6rsQjhITHK82y)
Learn Data Science & Machine Learning: Data Science and Machine Learning | WhatsApp Channel (https://whatsapp.com/channel/0029Va8v3eo1NCrQfGMseL2D)
ENJOY LEARNING 👍👍
👍2
List of Python Project Ideas 👨🏻💻🐍 -
Beginner Projects
🔹 Calculator
🔹 To-Do List
🔹 Number Guessing Game
🔹 Basic Web Scraper
🔹 Password Generator
🔹 Flashcard Quizzer
🔹 Simple Chatbot
🔹 Weather App
🔹 Unit Converter
🔹 Rock-Paper-Scissors Game
Intermediate Projects
🔸 Personal Diary
🔸 Web Scraping Tool
🔸 Expense Tracker
🔸 Flask Blog
🔸 Image Gallery
🔸 Chat Application
🔸 API Wrapper
🔸 Markdown to HTML Converter
🔸 Command-Line Pomodoro Timer
🔸 Basic Game with Pygame
Advanced Projects
🔺 Social Media Dashboard
🔺 Machine Learning Model
🔺 Data Visualization Tool
🔺 Portfolio Website
🔺 Blockchain Simulation
🔺 Chatbot with NLP
🔺 Multi-user Blog Platform
🔺 Automated Web Tester
🔺 File Organizer
Python Projects: https://whatsapp.com/channel/0029Vau5fZECsU9HJFLacm2a
Cool Coding Projects: https://whatsapp.com/channel/0029VazkxJ62UPB7OQhBE502/149
Beginner Projects
🔹 Calculator
🔹 To-Do List
🔹 Number Guessing Game
🔹 Basic Web Scraper
🔹 Password Generator
🔹 Flashcard Quizzer
🔹 Simple Chatbot
🔹 Weather App
🔹 Unit Converter
🔹 Rock-Paper-Scissors Game
Intermediate Projects
🔸 Personal Diary
🔸 Web Scraping Tool
🔸 Expense Tracker
🔸 Flask Blog
🔸 Image Gallery
🔸 Chat Application
🔸 API Wrapper
🔸 Markdown to HTML Converter
🔸 Command-Line Pomodoro Timer
🔸 Basic Game with Pygame
Advanced Projects
🔺 Social Media Dashboard
🔺 Machine Learning Model
🔺 Data Visualization Tool
🔺 Portfolio Website
🔺 Blockchain Simulation
🔺 Chatbot with NLP
🔺 Multi-user Blog Platform
🔺 Automated Web Tester
🔺 File Organizer
Python Projects: https://whatsapp.com/channel/0029Vau5fZECsU9HJFLacm2a
Cool Coding Projects: https://whatsapp.com/channel/0029VazkxJ62UPB7OQhBE502/149
👍6❤3