by Anonymous » 11 Apr 2025, 20:33
Ich habe einen Pandas DataFrame df . Es hat Multi-Index mit GX.region und Szenario_Model. Wenn ich es zeichne, kommt es in der gleichen Reihenfolge.
Ich möchte es jedoch als PES, TES und DES ordnen und es entsprechend darstellen. Ist es möglich, dies in Python Pandas DataFrame zu erreichen? < /P>
Code: Select all
dict = {('Value', 2023, 'BatteryStorage'): {('Central Africa', 'des'): 0.0,
('Central Africa', 'pes'): 0.0,
('Central Africa', 'tes'): 0.0,
('Eastern Africa', 'des'): 0.0,
('Eastern Africa', 'pes'): 0.0,
('Eastern Africa', 'tes'): 0.0,
('North Africa', 'des'): 0.0,
('North Africa', 'pes'): 0.0,
('North Africa', 'tes'): 0.0,
('Southern Africa', 'des'): 504.0,
('Southern Africa', 'pes'): 100.0,
('Southern Africa', 'tes'): 360.0,
('West Africa', 'des'): 0.0,
('West Africa', 'pes'): 0.0,
('West Africa', 'tes'): 0.0},
('Value', 2023, 'Biomass PP'): {('Central Africa', 'des'): 0.0,
('Central Africa', 'pes'): 0.0,
('Central Africa', 'tes'): 0.0,
('Eastern Africa', 'des'): 40,
('Eastern Africa', 'pes'): 10,
('Eastern Africa', 'tes'): 50,
('North Africa', 'des'): 0.0,
('North Africa', 'pes'): 0.0,
('North Africa', 'tes'): 0.0,
('Southern Africa', 'des'): 90.0,
('Southern Africa', 'pes'): 43.0,
('Southern Africa', 'tes'): 50.0,
('West Africa', 'des'): 200.0,
('West Africa', 'pes'): 150.0,
('West Africa', 'tes'): 100}}
df_sample = pd.DataFrame.from_dict(dict)
df_sample.plot(kind = "bar",
stacked = True)
Ich habe einen Pandas DataFrame df . Es hat Multi-Index mit GX.region und Szenario_Model. Wenn ich es zeichne, kommt es in der gleichen Reihenfolge. [url=viewtopic.php?t=14917]Ich möchte[/url] es jedoch als PES, TES und DES ordnen und es entsprechend darstellen. Ist es möglich, dies in Python Pandas DataFrame zu erreichen? < /P>
[code] dict = {('Value', 2023, 'BatteryStorage'): {('Central Africa', 'des'): 0.0,
('Central Africa', 'pes'): 0.0,
('Central Africa', 'tes'): 0.0,
('Eastern Africa', 'des'): 0.0,
('Eastern Africa', 'pes'): 0.0,
('Eastern Africa', 'tes'): 0.0,
('North Africa', 'des'): 0.0,
('North Africa', 'pes'): 0.0,
('North Africa', 'tes'): 0.0,
('Southern Africa', 'des'): 504.0,
('Southern Africa', 'pes'): 100.0,
('Southern Africa', 'tes'): 360.0,
('West Africa', 'des'): 0.0,
('West Africa', 'pes'): 0.0,
('West Africa', 'tes'): 0.0},
('Value', 2023, 'Biomass PP'): {('Central Africa', 'des'): 0.0,
('Central Africa', 'pes'): 0.0,
('Central Africa', 'tes'): 0.0,
('Eastern Africa', 'des'): 40,
('Eastern Africa', 'pes'): 10,
('Eastern Africa', 'tes'): 50,
('North Africa', 'des'): 0.0,
('North Africa', 'pes'): 0.0,
('North Africa', 'tes'): 0.0,
('Southern Africa', 'des'): 90.0,
('Southern Africa', 'pes'): 43.0,
('Southern Africa', 'tes'): 50.0,
('West Africa', 'des'): 200.0,
('West Africa', 'pes'): 150.0,
('West Africa', 'tes'): 100}}
df_sample = pd.DataFrame.from_dict(dict)
df_sample.plot(kind = "bar",
stacked = True)
[/code]