Question

In: Computer Science

I have an excel file imported into canopy (python) using import pandas as pd. The excel...

I have an excel file imported into canopy (python) using import pandas as pd. The excel file has headers titled:

datetime created_at PM25 temperatureF dewpointF    humidityPCNT windMPH    wind_speedMPH wind_gustsMPH pressureIN precipIN

these column headers all have thousands of data numbers under them. How could i find the average of all of the numbers in each column and plot them on 1 graph (line graph or scatter plot) Thank you.(please comment out your code)

Solutions

Expert Solution

Here is the code for the problem, I have omitted the date and created at columns on purpose because taking an average of dates do not make any sense.
I have used pyplot to plot the graph and pandas to import the excel file.

Here is the output

Here is the sample table that I used

In case you run the exact same code, I provided, remove the date and created at the column, because this code considers the plot without that.

if you liked the answer please upvote, and in case of any comments please ask in comments i will surely help.

Code:

#import panda and pyplot
import pandas as pd
import matplotlib.pyplot as plt

# read the excel file from the location you have stored it into
df = pd.read_excel (r'C:\Users\Public\tempData.xlsx')

# extract the name of the headings/parameters
x = list(df.columns.values)
# extract the mean of the data
y = list(df.mean())

# Code to plot the diagram

plt.figure(figsize=(9,9)) # this changes the size of the graph
# plot the graph
plt.plot(x, y,linewidth=2.0)
#set the title
plt.title('LinePlot of the given Data')
# set the x and y labels
plt.xlabel('Parameters')
plt.ylabel('Average Values')
plt.show()


Related Solutions

Python Question I have created a dictionary shown below: import pandas as pd records_dict = {'FirstName':...
Python Question I have created a dictionary shown below: import pandas as pd records_dict = {'FirstName': [ 'Jim', 'John', 'Helen'], 'LastName': [ 'Robertson', 'Adams', 'Cooper'], 'Zipcode': [ '21801', '22321-1143', 'edskd-2134'], 'Phone': [ '555-555-5555', '4444444444', '323232'] } I have stored this dictionary in a data frame, like shown below: records = pd.DataFrame(records_dict) print(records) I am able to print the records just fine. My issue is, I want to eliminate, or put a blank space in, the values of the zipcode and...
Explain if lines from "Import pandas as pd" to "#predicting the value" answers the questions to...
Explain if lines from "Import pandas as pd" to "#predicting the value" answers the questions to question 1. Also explain what is supposed to found using the lines "#income: avg. area income" to "#address." What does this mean "#Also try to see if the model performance can be improved with feature selection." #1. #Fit a linear regression model on data: USA_housing.csv to predict the Price of the house. import pandas as pd housing_df = pd.read_csv("USA_Housing.csv") from sklearn.linear_model import LinearRegression #loading...
Solve using PYTHON PROGRAMMING Write a script that reads a file “cars.csv”, into a pandas structure...
Solve using PYTHON PROGRAMMING Write a script that reads a file “cars.csv”, into a pandas structure and then print a. the first 3 rows and the last 3 of the dataset b. the 3 cars with the lowest average-mileage c. the 3 cars with the highest average-mileage. Solve using PYTHON PROGRAMMING
How can I use Python without Pandas to create a new.csv file with the headers "c1,...
How can I use Python without Pandas to create a new.csv file with the headers "c1, c2, c3, c4, c5, c6" and the first line of data "8, 5, -9, 7, 2.1, 1.7" from the original.csv file?
Pandas exercises: 1. Write a python program using Pandas to create and display a one-dimensional array-like...
Pandas exercises: 1. Write a python program using Pandas to create and display a one-dimensional array-like object containing an array of data. 2. Write a python program using Pandas to convert a Panda module Series to Python list and print it's type. (Hint: use ds.tolist() to convert the pandas series ds to a list) 3. Create a pandas dataframe called **my_df** with index as integer numbers between 0 to 10, first column (titled "rnd_int") as 10 integer random numbers between...
Python I am creating a class in python. Here is my code below: import csv import...
Python I am creating a class in python. Here is my code below: import csv import json population = list() with open('PopChange.csv', 'r') as p: reader = csv.reader(p) next(reader) for line in reader: population.append(obj.POP(line)) population.append(obj.POP(line)) class POP: """ Extract the data """ def __init__(self, line): self.data = line # get elements self.id = self.data[0].strip() self.geography = self.data[1].strip() self.targetGeoId = self.data[2].strip() self.targetGeoId2 = self.data[3].strip() self.popApr1 = self.data[4].strip() self.popJul1 = self.data[5].strip() self.changePop = self.data[6].strip() The problem is, I get an error saying:  ...
how to export source data to excel file in python?
how to export source data to excel file in python?
Python 3: I have a file with 53,000 entries or so of movies, the year they...
Python 3: I have a file with 53,000 entries or so of movies, the year they were made, the rating, length, and what genre they are. I need to get user input for the year, or the title, or the rating/genre/length. The genre is a 6 digit collection of 0's and 1's. The placement of 1's determines what genre they are (or a combination of genres). The genre,rating, and length are all one test and return entries that match all...
This is all in Python. Also, the names come from a .txt file that i have...
This is all in Python. Also, the names come from a .txt file that i have created with 3 names on it(Jim,Pam,Dwight). Main Function. Write a program where the user enters a name. Using the read function, check to see if the name is in the text document. If it is, respond back to the user the name is found within the list. Read Function. The read function should return the contents of the text document as a list. EXAMPLE...
Can you please solve these questions/ statements using python? I started with "importing" the file. I...
Can you please solve these questions/ statements using python? I started with "importing" the file. I only need question one to be answered not two-four. Can use whatever data frame of choice, I just need a sample code for each line. Thank you #1. #Fit a linear regression model on data: USA_housing.csv to predict the Price of the house. import pandas as pd housing_df = pd.read_csv("USA_Housing.csv") #Income: Avg. area income #Age: Avg age of the houses #Bedrooms: Avg No of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT