Unknown model· unknown
from ShareGPT 90K (shared ChatGPT conversations)
Create a Python script that reads data from the sheets…
- User
Create a Python script that reads data from the sheets "LMAR_T401","LMAR_T402","STUP_T401" in an Excel workbook called "ZTR_priebehy.xlsx". The script should use the data in columns B,C,D,E,F and G (headers: "Tech.kontrola dňa", "C2H2", "C2H4", "C2H6", "CO", "CH4") of every worksheets. Create a timeline graph for gas C2H2, next graph for C2H4, next for C2H6, next for CO and next for CH4.
- Assistant
Sure, here's a Python script that should accomplish what you're looking for using the Pandas and Matplotlib libraries:
pythonimport pandas as pd import matplotlib.pyplot as plt # Read in the Excel workbook workbook = pd.read_excel('ZTR_priebehy.xlsx', sheet_name=['LMAR_T401', 'LMAR_T402', 'STUP_T401']) # Define the columns we want to use columns = ['Tech.kontrola dňa', 'C2H2', 'C2H4', 'C2H6', 'CO', 'CH4'] # Loop over each gas and create a timeline graph for each one for gas in columns[1:]: fig, ax = plt.subplots() for sheet_name, sheet_data in workbook.items(): # Get the relevant data for this gas gas_data = sheet_data[columns].dropna(subset=[gas]) # Plot the data as a line ax.plot(gas_data['Tech.kontrola dňa'], gas_data[gas], label=sheet_name) # Set the axis labels and legend ax.set_xlabel('Date') ax.set_ylabel(gas) ax.set_title(f'{gas} timeline') ax.legend() plt.show()