0% found this document useful (0 votes)
3 views2 pages

Code Python

The document contains Python code that utilizes the pandas library to read and manipulate data from a CSV file, specifically focusing on columns labeled 'A' and 'B'. It also includes various matplotlib visualizations such as scatter plots, line plots, bar charts, and pie charts to represent mean temperature data and other categorical data. The code demonstrates data loading, sorting, and plotting techniques, along with saving a figure to a file.

Uploaded by

ishaanvi4444
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Code Python

The document contains Python code that utilizes the pandas library to read and manipulate data from a CSV file, specifically focusing on columns labeled 'A' and 'B'. It also includes various matplotlib visualizations such as scatter plots, line plots, bar charts, and pie charts to represent mean temperature data and other categorical data. The code demonstrates data loading, sorting, and plotting techniques, along with saving a figure to a file.

Uploaded by

ishaanvi4444
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

import pandas as pd

data = pd.read_csv('data.csv')
print(data.head())

import pandas as pd
data= pd.read_csv("data.csv")
data.dtypes

import pandas as pd
data = pd.read_csv('data.csv')
a = data.sort_values(by='A' ,ascending =True)
print(a.head())

import matplotlib.pyplot as plt


import numpy as np
x = data.A
y = data.B

plt.scatter(x,y)
plt.title('Mean Temperature at Jaipur')
plt.scatter(x,y, c='green', marker='*')
plt.show()
plt.xlabel ("Date", fontsize = 14)
plt.ylabel ("Mean Temperature", fontsize = 14)

plt.figure(figsize=(10,10))
y = data.A
plt.plot(x,y,"o:r")
plt.ylabel("Mean Temperature")
plt.xlabel("Time")
plt.legend()
plt.show()

import matplotlib.pyplot as plt


import numpy as np
plt.figure(figsize=(10,10))
plt.bar(x,y, align='center')
plt.show()
z=[50,23,34,9,56]
plt.pie(z)
plt.show()

z=[23,34,45,56]
mylabels = ["Apples", "Bananas", "Cherries", "Dates"]
myexplode = [0.2, 0, 0, 0]
plt.pie(z, labels = mylabels, explode = myexplode)
plt.legend()
plt.show()

plt.scatter(x,y)
plt.xticks(np.arange(0, 731, 60))
plt.xticks (rotation=90)
plt.savefig("graph1.png")
plt.show()

You might also like