You are on page 1of 1

#Reading data from EXCEL file, analysing and graph plots.

import pandas as pd
from google.colab import files #will help to use file system
import io #use to read and write data to files
import matplotlib.pyplot as plt
#####################################################
#If you are working on local machine use following code to read from python
#df = pd.read_excel ("D:\\folder1\folder2\\ds1.xlsx",sheet_name="Sheet1")
#print (df)
####################################################
filedata=files.upload() #this upload the file ie copying from local pc to google
cloud server
##df=pd.read_csv(io.BytesIO(filedata['ds1.csv']))
df=pd.read_excel(io.BytesIO(filedata['ds1.xlsx']),"Dataset") #not required for
local machine python installation
#print(df)
#print(df[['Name']]) #prints single column
print(df[['Name','Type 1']]) #prints multiple columns
print(df.isnull().sum()) #displays sum of null in each columns
hpmean=int(df["HP"].mean())
print("Mean is ",hpmean)
df["HP"].fillna(hpmean,inplace=True)
print(df["HP"])
#CHART
#df1=df.loc[df["Type 1"] == "Fire"] #loc function filters data
#df1=df.loc[df["Speed"] >= 140]
df1=df.loc[(df["Type 1"] == "Fire") & (df["Speed"] >=100)] #use | for or # loc
function filters the data

#print(df1)
plt.xlabel("Speed")
plt.ylabel("Name")
plt.barh (df1["Name"],df1["Speed"],color=["red","green"]) #will draw bar chart
#plt.bar (df1["Name"],df1["Speed"],color=["red","green"]) #will draw column chart

You might also like