This file contains 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 | |
# Making a score list | |
data = {'Subject': ['Math', 'English', 'Math', 'English', 'Math'], | |
'Score': [85, 90, 92, 88, 78]} | |
df = pd.DataFrame(data) | |
# Grouping by 'Subject' and finding the average score | |
grouped_data = df.groupby('Subject').mean() |
This file contains 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 seaborn as sns | |
import matplotlib.pyplot as plt | |
# Example Data (randomly generated) | |
data = sns.load_dataset("tips") | |
# Creating the Box Plot | |
sns.boxplot(x="day", y="total_bill", data=data, palette="Set2") | |
# Create a box plot of total bill amounts grouped by day, using the 'Set2' color palette |
This file contains 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 seaborn as sns | |
import matplotlib.pyplot as plt | |
import numpy as np | |
# Generating a synthetic correlation matrix | |
np.random.seed(42) | |
data = np.random.rand(10, 10) | |
# Creating the Heatmap | |
sns.heatmap(data, cmap="YlGnBu", annot=True, fmt=".2f", linewidths=.5) |
This file contains 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 matplotlib.pyplot as plt | |
import numpy as np | |
# Example Data (randomly generated) | |
data = np.random.randn(1000) * 30 + 50 # Creating a sample dataset with a normal distribution | |
# Creating the Histogram | |
plt.hist(data, bins=30, color='skyblue', edgecolor='black') | |
# Create a histogram with 30 bins, using skyblue color and black edges |
This file contains 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 matplotlib.pyplot as plt | |
# Example Data | |
categories = ['Category A', 'Category B', 'Category C', 'Category D'] | |
values = [25, 30, 20, 25] | |
# Creating the Pie Chart | |
plt.pie(values, labels=categories, autopct='%1.1f%%', startangle=90, colors=['#ff9999','#66b3ff','#99ff99','#ffcc99']) | |
# Create a pie chart with the given values and categories | |
# autopct displays the percentage on each slice, startangle rotates the chart, and colors customize each slice |
This file contains 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 matplotlib.pyplot as plt | |
# Example Data | |
study_hours = [3, 5, 7, 2, 6, 8, 4, 5, 7, 1] | |
exam_scores = [60, 75, 85, 50, 70, 90, 65, 80, 88, 45] | |
# Creating the Scatter Plot | |
plt.scatter(study_hours, exam_scores, color='blue', marker='o', label='Students') | |
# Scatter the points on the graph with study hours on the x-axis and exam scores on the y-axis | |
# Customize the appearance with a blue color, circular markers, and label the data as 'Students' |
This file contains 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 matplotlib.pyplot as plt | |
# Example Data | |
time = [1, 2, 3, 4, 5] # X-axis values (e.g., time) | |
values = [10, 12, 8, 15, 11] # Y-axis values (e.g., some measurement) | |
# Creating the Line Chart | |
plt.plot(time, values, marker='o', linestyle='-') # 'o' for markers, '-' for line style | |
# Adding Labels |
This file contains 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 matplotlib.pyplot as plt | |
# Example data | |
categories = ['Category A', 'Category B', 'Category C'] | |
values = [25, 40, 30] | |
# Bar chart | |
plt.bar(categories, values, color=['skyblue', 'salmon', 'lightgreen']) | |
plt.title('Bar Chart for Categorical Data') | |
plt.xlabel('Categories') |
This file contains 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 necessary libraries | |
import numpy as np | |
import pandas as pd | |
from sklearn.linear_model import LinearRegression | |
# Set a seed for reproducibility | |
np.random.seed(42) | |
# Simulate data for superheroes | |
superheroes_data = { |
This file contains 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 | |
from pandas_profiling import ProfileReport | |
import numpy as np | |
# Create a toy dataset | |
data = { | |
'Name': ['Paul', 'Pallabi', 'Peter', 'Gwen', 'Emily'], | |
'Age': [24, 23, 35, 22, 28], | |
'Salary': [50000, 60000, 75000, 45000, 55000], | |
'Gender': ['Male', 'Female', 'Male', 'Female', 'Female'], |
NewerOlder