Untitled
unknown
plain_text
10 months ago
902 B
11
Indexable
import pandas as pd
from sklearn.datasets import load_iris
# 1. Load dataset
iris = load_iris()
df = pd.DataFrame(iris.data, columns=iris.feature_names)
df["target"] = iris.target
print("\n--- Dataset Loaded ---")
print(df.head())
# 2. Explore data
print("\n--- Info ---")
print(df.info())
print("\n--- Description ---")
print(df.describe())
# 3. Handle missing values (Iris has no missing values, but just in case)
print("\n--- Missing values count ---")
print(df.isnull().sum())
# 4. Select/filter rows and columns
print("\n--- Select one column ---")
print(df["sepal length (cm)"].head())
print("\n--- Filter rows (sepal length > 5) ---")
print(df[df["sepal length (cm)"] > 5].head())
# 5. Perform basic statistics
print("\n--- Mean of petal length ---")
print(df["petal length (cm)"].mean())
# 6. Group data
print("\n--- Group by target and get mean ---")
print(df.groupby("target").mean())Editor is loading...
Leave a Comment