Created
December 24, 2024 04:58
-
-
Save Bhavya031/ccf2e29210d57cdbafd9683b17260dde to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
np.random.seed(42) | |
data = { | |
"Age": np.random.randint(18, 70, 100), | |
"Salary": np.random.randint(20000, 120000, 100), | |
"Experience": np.random.randint(1, 40, 100), | |
"Department": np.random.choice(["HR", "Finance", "Engineering", "Marketing"], 100) | |
} | |
df = pd.DataFrame(data) | |
print("### Summary Statistics ###") | |
print(df.describe()) | |
print("\n### Frequency Counts ###") | |
print(df["Department"].value_counts()) | |
print("\n### Missing Values ###") | |
print(df.isnull().sum()) | |
plt.figure(figsize=(10, 5)) | |
plt.subplot(1, 2, 1) | |
sns.histplot(df["Age"], kde=True, bins=15, color="blue") | |
plt.title("Age Distribution") | |
plt.xlabel("Age") | |
plt.ylabel("Frequency") | |
plt.subplot(1, 2, 2) | |
sns.boxplot(data=df, y="Salary", color="orange") | |
plt.title("Salary Boxplot") | |
plt.ylabel("Salary") | |
plt.tight_layout() | |
plt.show() | |
correlation = df.corr() | |
print("\n### Correlation Matrix ###") | |
print(correlation) | |
plt.figure(figsize=(8, 6)) | |
sns.heatmap(correlation, annot=True, cmap="coolwarm", fmt=".2f") | |
plt.title("Correlation Heatmap") | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment