Data Science — Python
Key libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
NumPy basics
arr = np.array([1, 2, 3, 4, 5])
print(arr.mean())
print(arr.std())
print(arr.reshape(5, 1))
Pandas basics
# Create DataFrame
df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
# Read CSV
df = pd.read_csv('data.csv')
# Select columns
df['A']
df[['A', 'B']]
# Filter
df[df['A'] > 1]
# Group by
df.groupby('category').mean()
Functions
def analyze_data(df):
return {
'shape': df.shape,
'dtypes': df.dtypes,
'missing': df.isnull().sum(),
'describe': df.describe()
}
List comprehensions
squares = [x**2 for x in range(10)]
even = [x for x in range(10) if x % 2 == 0]
Mini Practice
- Load data with Pandas
- Manipulate DataFrames
- Create visualizations
- Build analysis functions
Up Next
Continue with R - Statistical computing.
Related Topics
Frequently Asked Questions about Python
What is Python in Data Science?
Python is a fundamental concept in Data Science. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn Python?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Python.
Why is Python important in Data Science?
Python is essential for Data Science development. Understanding this concept will help you write better code and solve real-world problems more effectively.