简体   繁体   English

如何使用Dash Plotly和Pandas从CSV绘制数据

[英]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. 在具有四个工作表的excel电子表格中(这是A / B测试,工作表1是a_group_flights,工作表2是b_group_flights,工作表3是a_group_hotels,工作表4是b_group_hotels),我对绘制两个“ budget_price”列感兴趣和“ total_spend”在“ budget_datetime”显示的时间段内,并且这两行(budget_price和total_spend)重叠,以显示预算金额与您随时间实际支出的差额。

This is what the spreadsheet looks like: https://ibb.co/JHCf12z 这是电子表格的外观: 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. 我正在使用Dash Plotly,并希望使用Pandas阅读excel电子表格,然后将数据绘制在图形上。

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

Read the excel instead with 改为阅读excel

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 如果您的excel有一张以上的纸,只需

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 那你应该在这里检查一下你想要哪种情节

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM