Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91962613
plot_delegation_exp.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
Sat, Nov 16, 04:29
Size
1 KB
Mime Type
text/x-python
Expires
Mon, Nov 18, 04:29 (2 d)
Engine
blob
Format
Raw Data
Handle
22353531
Attached To
R10013 cop-mining-participants
plot_delegation_exp.py
View Options
import
pandas
as
pd
import
matplotlib.pyplot
as
plt
# TODO update to newer numbers of experience
def
plot
(
path
):
country_data
=
pd
.
DataFrame
(
columns
=
{
"meeting"
,
"USA"
,
"China"
,
"European Union"
,
"Saudi Arabia"
,
"Kenya"
,
"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"
)
total_EU
=
0
total_US
=
0
total_CN
=
0
total_SA
=
0
total_KE
=
0
total_CH
=
0
for
aff
,
people
in
grouped_by_country
:
if
aff
==
"Switzerland"
:
total_CH
=
people
[
"experience"
]
.
sum
()
/
len
(
people
)
elif
aff
==
"United States"
:
total_US
=
people
[
"experience"
]
.
sum
()
/
len
(
people
)
elif
aff
==
"China"
:
total_CN
=
people
[
"experience"
]
.
sum
()
/
len
(
people
)
elif
aff
.
lower
()
==
"european union"
or
aff
.
lower
()
==
"european community"
:
total_EU
=
people
[
"experience"
]
.
sum
()
/
len
(
people
)
elif
aff
==
"Saudi Arabia"
:
total_SA
=
people
[
"experience"
]
.
sum
()
/
len
(
people
)
elif
aff
==
"Kenya"
:
total_KE
=
people
[
"experience"
]
.
sum
()
/
len
(
people
)
country_data
=
country_data
.
append
({
"meeting"
:
"cop"
+
str
(
i
),
"USA"
:
total_US
,
"China"
:
total_CN
,
"European Union"
:
total_EU
,
"Saudi Arabia"
:
total_SA
,
"Kenya"
:
total_KE
,
"Switzerland"
:
total_CH
},
ignore_index
=
True
)
plot_data
=
country_data
.
set_index
(
"meeting"
)
plot_data
.
plot
(
kind
=
"line"
,
xlabel
=
"Meeting"
,
ylabel
=
"Experience Score"
,
title
=
"Experience score per party"
)
plt
.
show
()
Event Timeline
Log In to Comment