salary02/data_analysis.py

29 lines
738 B
Python
Raw Normal View History

2022-10-31 15:05:22 +08:00
import numpy as np
import pandas as pd
2023-01-18 22:21:22 +08:00
import matplotlib.pyplot as plt
2022-10-31 15:05:22 +08:00
2023-01-15 21:53:12 +08:00
num_time_step = 200
2022-10-31 15:05:22 +08:00
num_iter = 10
2023-01-18 22:21:22 +08:00
env_data = pd.DataFrame(pd.read_excel('env_data.xlsx', engine='openpyxl', sheet_name=0))
2022-10-31 15:05:22 +08:00
assert env_data.shape[0] == num_iter * (num_time_step + 1)
lst_df = []
for i in range(num_iter):
df_tmp = env_data.iloc[i * (num_time_step + 1): (i + 1) * (num_time_step + 1), 1:]
lst_df.append(df_tmp)
2023-01-18 22:21:22 +08:00
lst_column = lst_df[0].columns[1:]
for str_col in lst_column:
x = np.arange(num_time_step+1)
for df in lst_df:
y = np.array(df[str_col]).flatten()
plt.xlabel('t')
plt.ylabel(str_col)
plt.plot(x, y)
# plt.show()
# plt.close()
plt.savefig(f'{str_col}.pdf', bbox_inches="tight")