tg-me.com/pythonanalyst/949
Last Update:
Python for Data Analytics - Quick Cheatsheet with Cod e Example 🚀
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://www.tg-me.com/sqlspecialist
Hope it helps :)
BY Python for Data Analysts
Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283
Share with your friend now:
tg-me.com/pythonanalyst/949