Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F88455427
plot_delegation_sizes.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Oct 18, 21:24
Size
1 KB
Mime Type
text/x-python
Expires
Sun, Oct 20, 21:24 (2 d)
Engine
blob
Format
Raw Data
Handle
21773530
Attached To
R10013 cop-mining-participants
plot_delegation_sizes.py
View Options
import
pandas
as
pd
import
matplotlib.pyplot
as
plt
def
plot
(
path
):
country_data
=
pd
.
DataFrame
(
columns
=
{
"meeting"
,
"USA"
,
"China"
,
"Germany"
,
"Saudi Arabia"
,
"Brazil"
,
"Switzerland"
})
complete_data
=
pd
.
read_csv
(
path
,
encoding
=
"utf-8-sig"
)
for
i
in
range
(
1
,
26
):
data
=
complete_data
[
complete_data
[
"meeting"
]
==
"cop"
+
str
(
i
)]
grouped_by_country
=
data
.
groupby
(
"affiliation"
)
try
:
total_DE
=
len
(
grouped_by_country
.
get_group
(
"Germany"
))
total_US
=
len
(
grouped_by_country
.
get_group
(
"United States"
))
total_CN
=
len
(
grouped_by_country
.
get_group
(
"China"
))
total_SA
=
len
(
grouped_by_country
.
get_group
(
"Saudi Arabia"
))
total_BR
=
len
(
grouped_by_country
.
get_group
(
"Brazil"
))
total_CH
=
len
(
grouped_by_country
.
get_group
(
"Switzerland"
))
except
KeyError
:
print
(
i
)
print
(
f
"{total_DE} DE and {total_US} US and {total_CN} CN and {total_SA} SA and {total_BR} BR and {total_CH} CH"
)
total_DE
=
0
total_US
=
0
total_CN
=
0
total_SA
=
0
total_BR
=
0
total_CH
=
0
country_data
=
country_data
.
append
({
"meeting"
:
"cop"
+
str
(
i
),
"USA"
:
total_US
,
"China"
:
total_CN
,
"Germany"
:
total_DE
,
"Saudi Arabia"
:
total_SA
,
"Brazil"
:
total_BR
,
"Switzerland"
:
total_CH
},
ignore_index
=
True
)
total_DE
=
0
total_US
=
0
total_CN
=
0
total_SA
=
0
total_BR
=
0
total_CH
=
0
plot_data4
=
country_data
.
set_index
(
"meeting"
)
plot_data4
.
plot
(
kind
=
"line"
,
xlabel
=
"Meeting"
,
ylabel
=
"Delegation size"
,
title
=
"Delegation size"
,
ylim
=
(
0
,
600
))
plt
.
show
()
Event Timeline
Log In to Comment