Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Moncora
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
halleyUIS
Moncora
Commits
abe055f2
Commit
abe055f2
authored
2 years ago
by
Laura Marcela Becerra
Browse files
Options
Downloads
Patches
Plain Diff
delate datos I
parent
45448356
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Book/Jupyter_Notebooks/.ipynb_checkpoints/DatosI-checkpoint.ipynb
+0
-120
0 additions, 120 deletions
...yter_Notebooks/.ipynb_checkpoints/DatosI-checkpoint.ipynb
Book/Jupyter_Notebooks/DatosI.ipynb
+0
-120
0 additions, 120 deletions
Book/Jupyter_Notebooks/DatosI.ipynb
with
0 additions
and
240 deletions
Book/Jupyter_Notebooks/.ipynb_checkpoints/DatosI-checkpoint.ipynb
+
0
−
120
View file @
abe055f2
...
@@ -8,126 +8,6 @@
...
@@ -8,126 +8,6 @@
"\n"
"\n"
]
]
},
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib widget\n",
"import plotly.graph_objs as go\n",
"from ipywidgets import interactive, HBox, VBox\n",
"import pandas as pd\n",
"import numpy as np\n",
"\n",
"\n",
"#df = pd.read_csv(r'https://nyc3.digitaloceanspaces.com/owid-public/data/co2/owid-co2-data.csv')\n",
"df = pd.read_csv('../datos/owid-co2-data.csv')\n",
"\n",
"continents = ['Europe','North America','South America','Asia','Oceania']\n",
"co2continents = df[df['country'].isin(continents)]\n",
"\n",
"co2continents = co2continents.rename(columns={\"country\": \"Región\"}) "
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "51ecf4198d974539a051f87e0a2501d6",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(HBox(children=(Dropdown(description='Plot', options=('co2', 'share_global_co2'), value='co2'), …"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import plotly.offline as py\n",
"from IPython.display import display\n",
"\n",
"fig = go.FigureWidget()\n",
"\n",
"labels = ['Europa','América del Norte','América del Sur','Asia','Oceania']\n",
"ymax = co2continents[\"year\"].max()+10\n",
"ymin = co2continents[\"year\"].min()-10\n",
"\n",
"i=0\n",
"for c in continents:\n",
" df = co2continents[co2continents['Región']== c ]\n",
" fig.add_scatter( x = df['year'], y = df['co2'] , name=labels[i]#,text=\"año:\"\n",
" )\n",
" i+=1\n",
" \n",
"fig.update_layout ( \n",
" xaxis_title=\"Año\",\n",
" yaxis_title=\"co2 [Toneladas]\",\n",
" autosize=False,\n",
" width=800,\n",
" height=500,\n",
" margin=dict(\n",
" l=50,\n",
" r=50,\n",
" b=50,\n",
" t=50,\n",
" pad=4),\n",
" legend_title=\"Región\",\n",
" title = 'Esmisión anual de CO2',\n",
" font=dict(\n",
" family=\"Rockwell\",\n",
" size=16,\n",
" #color=\"RebeccaPurple\"\n",
" ),\n",
" plot_bgcolor='rgba(0,0,0,0)'\n",
")\n",
"\n",
"fig.update_xaxes(\n",
" ticks='outside',\n",
" showline=True,\n",
" linecolor='black',\n",
" gridcolor='lightgrey',\n",
" range=[ymin,ymax]\n",
")\n",
"fig.update_yaxes(\n",
" ticks='outside',\n",
" showline=True,\n",
" linecolor='black',\n",
" gridcolor='lightgrey'\n",
")\n",
"\n",
"def update_axes(Plot):\n",
" i=0\n",
" for c in continents:\n",
" df = co2continents[co2continents['Región']== c ]\n",
" scatter = fig.data[i]\n",
" scatter.x = df['year']\n",
" scatter.y = df[Plot]\n",
" scatter.name=labels[i]\n",
" i+=1\n",
" if Plot == \"co2\":\n",
" ylabel=\"co2 [Toneladas]\" \n",
" else:\n",
" ylabel=\"Porcentaje global\"\n",
" fig.update_layout ( \n",
" yaxis_title = ylabel )\n",
"\n",
"axis_dropdowns = interactive(update_axes, Plot = [\"co2\",\"share_global_co2\"])\n",
"\n",
"mybox = VBox([HBox(axis_dropdowns.children),fig])\n",
"\n",
"\n",
"display(mybox)\n",
"#fig.show() \n"
]
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": null,
"execution_count": null,
...
...
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
# Conociendo los datos
# Conociendo los datos
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
%
matplotlib
widget
import
plotly.graph_objs
as
go
from
ipywidgets
import
interactive
,
HBox
,
VBox
import
pandas
as
pd
import
numpy
as
np
#df = pd.read_csv(r'https://nyc3.digitaloceanspaces.com/owid-public/data/co2/owid-co2-data.csv')
df
=
pd
.
read_csv
(
'
../datos/owid-co2-data.csv
'
)
continents
=
[
'
Europe
'
,
'
North America
'
,
'
South America
'
,
'
Asia
'
,
'
Oceania
'
]
co2continents
=
df
[
df
[
'
country
'
].
isin
(
continents
)]
co2continents
=
co2continents
.
rename
(
columns
=
{
"
country
"
:
"
Región
"
})
```
%% Cell type:code id: tags:
```
python
import
plotly.offline
as
py
from
IPython.display
import
display
fig
=
go
.
FigureWidget
()
labels
=
[
'
Europa
'
,
'
América del Norte
'
,
'
América del Sur
'
,
'
Asia
'
,
'
Oceania
'
]
ymax
=
co2continents
[
"
year
"
].
max
()
+
10
ymin
=
co2continents
[
"
year
"
].
min
()
-
10
i
=
0
for
c
in
continents
:
df
=
co2continents
[
co2continents
[
'
Región
'
]
==
c
]
fig
.
add_scatter
(
x
=
df
[
'
year
'
],
y
=
df
[
'
co2
'
]
,
name
=
labels
[
i
]
#,text="año:"
)
i
+=
1
fig
.
update_layout
(
xaxis_title
=
"
Año
"
,
yaxis_title
=
"
co2 [Toneladas]
"
,
autosize
=
False
,
width
=
800
,
height
=
500
,
margin
=
dict
(
l
=
50
,
r
=
50
,
b
=
50
,
t
=
50
,
pad
=
4
),
legend_title
=
"
Región
"
,
title
=
'
Esmisión anual de CO2
'
,
font
=
dict
(
family
=
"
Rockwell
"
,
size
=
16
,
#color="RebeccaPurple"
),
plot_bgcolor
=
'
rgba(0,0,0,0)
'
)
fig
.
update_xaxes
(
ticks
=
'
outside
'
,
showline
=
True
,
linecolor
=
'
black
'
,
gridcolor
=
'
lightgrey
'
,
range
=
[
ymin
,
ymax
]
)
fig
.
update_yaxes
(
ticks
=
'
outside
'
,
showline
=
True
,
linecolor
=
'
black
'
,
gridcolor
=
'
lightgrey
'
)
def
update_axes
(
Plot
):
i
=
0
for
c
in
continents
:
df
=
co2continents
[
co2continents
[
'
Región
'
]
==
c
]
scatter
=
fig
.
data
[
i
]
scatter
.
x
=
df
[
'
year
'
]
scatter
.
y
=
df
[
Plot
]
scatter
.
name
=
labels
[
i
]
i
+=
1
if
Plot
==
"
co2
"
:
ylabel
=
"
co2 [Toneladas]
"
else
:
ylabel
=
"
Porcentaje global
"
fig
.
update_layout
(
yaxis_title
=
ylabel
)
axis_dropdowns
=
interactive
(
update_axes
,
Plot
=
[
"
co2
"
,
"
share_global_co2
"
])
mybox
=
VBox
([
HBox
(
axis_dropdowns
.
children
),
fig
])
display
(
mybox
)
#fig.show()
```
%% Output
%% Cell type:code id: tags:
```
python
``
`
``
`
%%
Cell
type
:
code
id
:
tags
:
%%
Cell
type
:
code
id
:
tags
:
```
python
```
python
```
```
...
...
This diff is collapsed.
Click to expand it.
Book/Jupyter_Notebooks/DatosI.ipynb
+
0
−
120
View file @
abe055f2
...
@@ -8,126 +8,6 @@
...
@@ -8,126 +8,6 @@
"\n"
"\n"
]
]
},
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib widget\n",
"import plotly.graph_objs as go\n",
"from ipywidgets import interactive, HBox, VBox\n",
"import pandas as pd\n",
"import numpy as np\n",
"\n",
"\n",
"#df = pd.read_csv(r'https://nyc3.digitaloceanspaces.com/owid-public/data/co2/owid-co2-data.csv')\n",
"df = pd.read_csv('../datos/owid-co2-data.csv')\n",
"\n",
"continents = ['Europe','North America','South America','Asia','Oceania']\n",
"co2continents = df[df['country'].isin(continents)]\n",
"\n",
"co2continents = co2continents.rename(columns={\"country\": \"Región\"}) "
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "51ecf4198d974539a051f87e0a2501d6",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(HBox(children=(Dropdown(description='Plot', options=('co2', 'share_global_co2'), value='co2'), …"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import plotly.offline as py\n",
"from IPython.display import display\n",
"\n",
"fig = go.FigureWidget()\n",
"\n",
"labels = ['Europa','América del Norte','América del Sur','Asia','Oceania']\n",
"ymax = co2continents[\"year\"].max()+10\n",
"ymin = co2continents[\"year\"].min()-10\n",
"\n",
"i=0\n",
"for c in continents:\n",
" df = co2continents[co2continents['Región']== c ]\n",
" fig.add_scatter( x = df['year'], y = df['co2'] , name=labels[i]#,text=\"año:\"\n",
" )\n",
" i+=1\n",
" \n",
"fig.update_layout ( \n",
" xaxis_title=\"Año\",\n",
" yaxis_title=\"co2 [Toneladas]\",\n",
" autosize=False,\n",
" width=800,\n",
" height=500,\n",
" margin=dict(\n",
" l=50,\n",
" r=50,\n",
" b=50,\n",
" t=50,\n",
" pad=4),\n",
" legend_title=\"Región\",\n",
" title = 'Esmisión anual de CO2',\n",
" font=dict(\n",
" family=\"Rockwell\",\n",
" size=16,\n",
" #color=\"RebeccaPurple\"\n",
" ),\n",
" plot_bgcolor='rgba(0,0,0,0)'\n",
")\n",
"\n",
"fig.update_xaxes(\n",
" ticks='outside',\n",
" showline=True,\n",
" linecolor='black',\n",
" gridcolor='lightgrey',\n",
" range=[ymin,ymax]\n",
")\n",
"fig.update_yaxes(\n",
" ticks='outside',\n",
" showline=True,\n",
" linecolor='black',\n",
" gridcolor='lightgrey'\n",
")\n",
"\n",
"def update_axes(Plot):\n",
" i=0\n",
" for c in continents:\n",
" df = co2continents[co2continents['Región']== c ]\n",
" scatter = fig.data[i]\n",
" scatter.x = df['year']\n",
" scatter.y = df[Plot]\n",
" scatter.name=labels[i]\n",
" i+=1\n",
" if Plot == \"co2\":\n",
" ylabel=\"co2 [Toneladas]\" \n",
" else:\n",
" ylabel=\"Porcentaje global\"\n",
" fig.update_layout ( \n",
" yaxis_title = ylabel )\n",
"\n",
"axis_dropdowns = interactive(update_axes, Plot = [\"co2\",\"share_global_co2\"])\n",
"\n",
"mybox = VBox([HBox(axis_dropdowns.children),fig])\n",
"\n",
"\n",
"display(mybox)\n",
"#fig.show() \n"
]
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": null,
"execution_count": null,
...
...
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
# Conociendo los datos
# Conociendo los datos
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
%
matplotlib
widget
import
plotly.graph_objs
as
go
from
ipywidgets
import
interactive
,
HBox
,
VBox
import
pandas
as
pd
import
numpy
as
np
#df = pd.read_csv(r'https://nyc3.digitaloceanspaces.com/owid-public/data/co2/owid-co2-data.csv')
df
=
pd
.
read_csv
(
'
../datos/owid-co2-data.csv
'
)
continents
=
[
'
Europe
'
,
'
North America
'
,
'
South America
'
,
'
Asia
'
,
'
Oceania
'
]
co2continents
=
df
[
df
[
'
country
'
].
isin
(
continents
)]
co2continents
=
co2continents
.
rename
(
columns
=
{
"
country
"
:
"
Región
"
})
```
%% Cell type:code id: tags:
```
python
import
plotly.offline
as
py
from
IPython.display
import
display
fig
=
go
.
FigureWidget
()
labels
=
[
'
Europa
'
,
'
América del Norte
'
,
'
América del Sur
'
,
'
Asia
'
,
'
Oceania
'
]
ymax
=
co2continents
[
"
year
"
].
max
()
+
10
ymin
=
co2continents
[
"
year
"
].
min
()
-
10
i
=
0
for
c
in
continents
:
df
=
co2continents
[
co2continents
[
'
Región
'
]
==
c
]
fig
.
add_scatter
(
x
=
df
[
'
year
'
],
y
=
df
[
'
co2
'
]
,
name
=
labels
[
i
]
#,text="año:"
)
i
+=
1
fig
.
update_layout
(
xaxis_title
=
"
Año
"
,
yaxis_title
=
"
co2 [Toneladas]
"
,
autosize
=
False
,
width
=
800
,
height
=
500
,
margin
=
dict
(
l
=
50
,
r
=
50
,
b
=
50
,
t
=
50
,
pad
=
4
),
legend_title
=
"
Región
"
,
title
=
'
Esmisión anual de CO2
'
,
font
=
dict
(
family
=
"
Rockwell
"
,
size
=
16
,
#color="RebeccaPurple"
),
plot_bgcolor
=
'
rgba(0,0,0,0)
'
)
fig
.
update_xaxes
(
ticks
=
'
outside
'
,
showline
=
True
,
linecolor
=
'
black
'
,
gridcolor
=
'
lightgrey
'
,
range
=
[
ymin
,
ymax
]
)
fig
.
update_yaxes
(
ticks
=
'
outside
'
,
showline
=
True
,
linecolor
=
'
black
'
,
gridcolor
=
'
lightgrey
'
)
def
update_axes
(
Plot
):
i
=
0
for
c
in
continents
:
df
=
co2continents
[
co2continents
[
'
Región
'
]
==
c
]
scatter
=
fig
.
data
[
i
]
scatter
.
x
=
df
[
'
year
'
]
scatter
.
y
=
df
[
Plot
]
scatter
.
name
=
labels
[
i
]
i
+=
1
if
Plot
==
"
co2
"
:
ylabel
=
"
co2 [Toneladas]
"
else
:
ylabel
=
"
Porcentaje global
"
fig
.
update_layout
(
yaxis_title
=
ylabel
)
axis_dropdowns
=
interactive
(
update_axes
,
Plot
=
[
"
co2
"
,
"
share_global_co2
"
])
mybox
=
VBox
([
HBox
(
axis_dropdowns
.
children
),
fig
])
display
(
mybox
)
#fig.show()
```
%% Output
%% Cell type:code id: tags:
```
python
``
`
``
`
%%
Cell
type
:
code
id
:
tags
:
%%
Cell
type
:
code
id
:
tags
:
```
python
```
python
```
```
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment