2303A54054 - Lab Assignment 2 - Colab
2303A54054 - Lab Assignment 2 - Colab
Lab Assignment - 2
Registation no : 2303A54054
Batch no : 47
Q) You have been provided with a CSV file named csv, which contains sales data for different products over multiple weeks. Your task is to use
Pandas and Matplotlib to read the CSV file and create a stacked bar chart that shows the total sales for each week, broken down by product
category. Make sure to include a legend, axis labels, and a title to clearly convey the sales trends across the weeks.
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv("/content/drive/MyDrive/DA dataset heights/weekdataset.csv")
df.head()
df.plot(kind='bar',x='Days',title='Mela Sales Repoort')
plt.ylabel('sales in Rs')
plt.show()
-->Note that - heatmap showing student performance across different subjects. Each cell in the heatmap represents a student's score in a
particular subject, with the color indicating the performance level.#The color ranges from light yellow (lower scores) to dark blue (higher
scores).
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
data = {
'Student': ['John', 'Jane', 'Mike', 'Emma', 'Lucy'],
'Math': [88, 78, 91, 84, 79],
'Science': [92, 85, 89, 87, 80],
'English': [85, 90, 82, 91, 84],
'History': [79, 88, 93, 85, 81],
'Art': [95, 76, 89, 88, 83]
}
df = pd.DataFrame(data)
df.set_index('Student', inplace=True)
plt.figure(figsize=(10, 6))
sns.heatmap(df, annot=True, cmap="YlGnBu", cbar=True)
plt.title('Student Performance Heatmap')
plt.show()
Q) You are tasked with analyzing the daily ticket sales for a week-long event. You have data on the number of tickets sold each day. Create a bar
chart using Matplotlib to visualize the day-wise distribution of ticket sales. Label the axes, provide a suitable title, and use different colors for
each bar to make the chart visually appealing and easy to interpret. x=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]
y=[2000,2800,3000,2500,2300,2500,1000]
import pandas as pd
import matplotlib.pyplot as plt
x = ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]
y = [2000,2800,3000,2500,2300,2500,1000]
plt.plot(x,y,color="magenta",marker ="*", label = "No.of tickets")
plt.title("Day wise Tickets sold")
plt.xlabel("Days")
plt.ylabel("No.of tickets sold")
plt.legend()
plt.grid(True)
#plt.savefig("d:/ Tickets.jpg")
plt.show()