1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| import pandas as pd from pyecharts import Bar3D
csv_file_path = 'data.csv' df = pd.read_csv(csv_file_path, header=None)
years = df.iloc[1:12, 1].tolist() months = list(df.iloc[0, 2:]) data = [] max_flow = 8580 min_flow = 6456
for year in years: for i, month in enumerate(months): value = float(df.iloc[years.index(year) + 111, months.index(month) + 2]) print(value) if value > max_flow: max_flow = value if value < min_flow: min_flow = value data.append([year, month, value])
bar3d = Bar3D("St. Lawrence River - Flow at Cornwall", width=800, height=600) x_axis = years y_axis = months range_color = ['#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf', '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026']
bar3d.add("", x_axis, y_axis, data, is_visualmap=True, visual_range=[min_flow, max_flow], line_opacity=1, grid3d_shading="lambert", visual_range_color=['#e0f3f8', '#2260b3'] )
bar3d.render()
|