Victor M
Victor M

Reputation: 27

How to plot data from csv using Dash Plotly and Pandas

In an excel spreadsheet with four sheets (this is an A/B test, Sheet 1 is a_group_flights, Sheet 2 is b_group_flights, Sheet 3 is a_group_hotels, Sheet 4 is b_group_hotels), I'm interested in plotting two of the columns "budget_price" and "total_spend" over a time period shown by "budget_datetime" and have those two lines (budget_price and total_spend) overlap to show the difference between what your budget is and how much you're actually spending over time on trips.

This is what the spreadsheet looks like: https://ibb.co/JHCf12z

I am using Dash Plotly and want to read the excel spreadsheet with Pandas, and then plot the data on a graph.

xlsx = pd.ExcelFile('data.xlsx')

Upvotes: 0

Views: 1812

Answers (1)

Jose Angel Sanchez
Jose Angel Sanchez

Reputation: 764

Read the excel instead with

xlsx = pd.read_excel('your_excel_file.xls') 

To make a simple line plot just make

df = xlsx
data = [go.Scatter( x=df['X_axis_column'], y=df['first_y_data', 'second_y_data'] )]

If your excel has more than one sheet, just make

df1 = pd.read_excel('exel_file.xls', 'Sheet1')
df2 = pd.read_excel('exel_file.xls', 'Sheet2')

Then you should check here to see which kind of plot you want

Upvotes: 1

Related Questions