Hey, so I am new to programming overall but I’ve been doing some data analysis. Okay so I have a module which reads an excel spreadsheet of 3 columns and returns a mean for the 2 output values I want.
I would like to import the mean from this, I’m assuming it’s the function I will be importing this into main() which will then plot a bar chart of wide form input. I have tried looking at how to import the dataframe into main() but I cannot follow it.
Here’s the code for the module:
import pandas as pd
#insert the pathway to the Excel file
Borough = ["Chelsea", "Kensington", "Westminster", "Pimlico", "Bank", "Holborn", "Camden", "Islington", "Angel", "Battersea", "Knightsbridge", "Bermondsey", "Newham"]
file = "/Users//Documents/Ideas/Python Data /realestate70kdata.xlsx"
df = pd.ExcelFile("/Users//Documents/Ideas/Python Data /realestate70kdata.xlsx").parse("realestatemodel")
x = []
x.append(df["Price"])
groupmean = df.groupby('Borough').mean()
print(f"Data mean is: {groupmean}")
Using the following example:
import plotly.express as px
import medianmodeltest1 as mean
df = px.data.mean()
fig = px.bar(df, x="nation", y="amount", color="medal", title="Wide-Form Input")
fig.show()
medianmodeltest1 is the module but the error which is returned is the df = px.data.mean()
Thanks in advance I deeply appreciate it!