Skip to content

Commit fd8f35d

Browse files
authored
Read Data from a CSV File
Hi, I have added Python code to read data from a .csv file using Pandas and plot the data using matplotlib
1 parent 5ffc138 commit fd8f35d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

ReadFromCSV.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
__author__ = 'vamsi'
2+
import pandas as pd
3+
import matplotlib.pyplot as plt
4+
from matplotlib import style
5+
6+
style.use("ggplot")
7+
8+
"""reading data from SalesData.csv file
9+
and passing data to dataframe"""
10+
11+
df=pd.read_csv("C:\\Users\\Test\\Desktop\\SalesData.csv")
12+
x=df["SalesID"].tolist()#casting SalesID to list
13+
y=df["ProductPrice"].tolist()#casting ProductPrice to list
14+
plt.xlabel("SalesID")#assigning X-axis label
15+
plt.ylabel("ProductPrice")#assigning Y-axis label
16+
plt.title("Sales Analysis")#assigning Title to the graph
17+
plt.plot(x,y)#Plot X and Y axis
18+
plt.show()#Show the graph

0 commit comments

Comments
 (0)