Scatter Plot:
import matplotlib.pyplot as plt
marks = [80, 75, 62, 90, 30]
subjects = ['Math', 'Hindi', 'English', 'AI', 'Science']
plt.scatter(subjects, marks, color='red')
plt.title("Subject Marks")
plt.xlabel("Subjects")
plt.ylabel("Marks")
plt.show()
Line plot:
import matplotlib.pyplot as plt
temp = [45, 25, 35, 27, 30]
cities = ['Delhi', 'Assam', 'Chennai', 'Hyderabad', 'Goa']
plt.plot(cities, temp, c='blue')
plt.title("Temperature in Different Cities")
plt.xlabel("Cities")
plt.ylabel("Temperature")
plt.show()
Bar Plot:
import matplotlib.pyplot as plt
medals = [45, 25, 35, 27, 30]
countries = ['Delhi', 'Assam', 'Chennai', 'Hyderabad', 'Goa']
plt.bar(countries, medals, color='yellow')
plt.title("Country-wise Medals")
plt.xlabel("Countries")
plt.ylabel("Medals")
plt.show()
# To read the CSV file into a variable
s = pd.read_csv("<path of the CSV file>") # Replace <path of the CSV file> with your actual
file path
# To print the first five rows
print(s.head())
# To print the top ten rows
print(s.head(10))
# To sort the rows by a specific column in ascending order
s_sorted = s.sort_values(by='Name') # For ascending order (default)
# To sort the rows by a specific column in descending order
s_sorted_desc = s.sort_values(by='Name', ascending=False)
# To print the last five rows
print(s.tail())
# To print the last ten rows
print(s.tail(10))