Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ejercicios-clase-08-datos
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
Juan David Hernandez Ramirez
ejercicios-clase-08-datos
Commits
7bfd4af7
Commit
7bfd4af7
authored
4 years ago
by
Arturo Sanchez
Browse files
Options
Downloads
Patches
Plain Diff
primer analisis datos
parent
529bebca
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
codigo/trabajo.ipynb
+233
-0
233 additions, 0 deletions
codigo/trabajo.ipynb
data-used/analisis.csv
+1
-1
1 addition, 1 deletion
data-used/analisis.csv
with
235 additions
and
1 deletion
.gitignore
0 → 100644
+
1
−
0
View file @
7bfd4af7
.ipynb_checkpoints/
This diff is collapsed.
Click to expand it.
codigo/trabajo.ipynb
0 → 100644
+
233
−
0
View file @
7bfd4af7
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"import pandas as pd\n",
"import csv\n",
"import numpy as np\n",
"import matplotlib as plt\n",
"import seaborn as sns"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df_species = pd.read_csv(\"~/ejercicios-clase-08-datos/data-used/species.csv\")\n",
"df_surveys = pd.read_csv(\"~/ejercicios-clase-08-datos/data-used/surveys.csv\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"pip install --upgrade pip"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df_species.head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df_surveys.head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df_surveys"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df_species['species_id'].unique()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df_surveys['species_id'].unique()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df_surveysspecie= pd.merge(df_surveys,df_species,how='left',on=['species_id'])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df_surveysspecie"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df_group_specie_id = df_surveysspecie.groupby('taxa').unique()\n",
"df_group_specie_id"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plt.pyplot.scatter(df_surveysspecie[df_surveysspecie['weight']>0],df_surveysspecie[df_surveysspecie['hindfoot_length']>0]['weight'])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plt.pyplot.scatter(df_surveysspecie[df_surveysspecie['taxa']=='Rodent'][df_surveysspecie['hindfoot_length']>0]['year'],df_surveysspecie[df_surveysspecie['taxa']=='Rodent'][df_surveysspecie['hindfoot_length']>0]['hindfoot_length'])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df_surveysspecie[df_surveysspecie['taxa']=='Rodent']['weight']"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df_surveysspecie.info()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df_surveysspecie['hindfoot_length']=df_surveysspecie['hindfoot_length'].fillna(0)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df_surveysspecie['weight']=df_surveysspecie['weight'].fillna(0)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plt.pyplot.scatter(df_surveysspecie['taxa'](skipna=True),df_surveysspecie['weight'])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df_surveysspecie['taxa'].hist()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df_surveysspecie['taxa'].unique()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df_surveysspecie[df_surveysspecie['weight']>0]['weight'].max()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df_weight_vs_taxa= pd.concat([df_surveysspecie[df_surveysspecie['weight']>0]['weight'],df_surveysspecie[df_surveysspecie['weight']>0]['taxa']],axis=1)\n",
"f,ax=plt.subplots()\n",
"fig"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
%% Cell type:code id: tags:
```
python
import
pandas
as
pd
import
csv
import
numpy
as
np
import
matplotlib
as
plt
import
seaborn
as
sns
```
%% Cell type:code id: tags:
```
python
df_species
=
pd
.
read_csv
(
"
~/ejercicios-clase-08-datos/data-used/species.csv
"
)
df_surveys
=
pd
.
read_csv
(
"
~/ejercicios-clase-08-datos/data-used/surveys.csv
"
)
```
%% Cell type:code id: tags:
```
python
pip
install
--
upgrade
pip
```
%% Cell type:code id: tags:
```
python
df_species
.
head
()
```
%% Cell type:code id: tags:
```
python
df_surveys
.
head
()
```
%% Cell type:code id: tags:
```
python
df_surveys
```
%% Cell type:code id: tags:
```
python
df_species
[
'
species_id
'
].
unique
()
```
%% Cell type:code id: tags:
```
python
df_surveys
[
'
species_id
'
].
unique
()
```
%% Cell type:code id: tags:
```
python
df_surveysspecie
=
pd
.
merge
(
df_surveys
,
df_species
,
how
=
'
left
'
,
on
=
[
'
species_id
'
])
```
%% Cell type:code id: tags:
```
python
df_surveysspecie
```
%% Cell type:code id: tags:
```
python
df_group_specie_id
=
df_surveysspecie
.
groupby
(
'
taxa
'
).
unique
()
df_group_specie_id
```
%% Cell type:code id: tags:
```
python
plt
.
pyplot
.
scatter
(
df_surveysspecie
[
df_surveysspecie
[
'
weight
'
]
>
0
],
df_surveysspecie
[
df_surveysspecie
[
'
hindfoot_length
'
]
>
0
][
'
weight
'
])
```
%% Cell type:code id: tags:
```
python
plt
.
pyplot
.
scatter
(
df_surveysspecie
[
df_surveysspecie
[
'
taxa
'
]
==
'
Rodent
'
][
df_surveysspecie
[
'
hindfoot_length
'
]
>
0
][
'
year
'
],
df_surveysspecie
[
df_surveysspecie
[
'
taxa
'
]
==
'
Rodent
'
][
df_surveysspecie
[
'
hindfoot_length
'
]
>
0
][
'
hindfoot_length
'
])
```
%% Cell type:code id: tags:
```
python
df_surveysspecie
[
df_surveysspecie
[
'
taxa
'
]
==
'
Rodent
'
][
'
weight
'
]
```
%% Cell type:code id: tags:
```
python
df_surveysspecie
.
info
()
```
%% Cell type:code id: tags:
```
python
df_surveysspecie
[
'
hindfoot_length
'
]
=
df_surveysspecie
[
'
hindfoot_length
'
].
fillna
(
0
)
```
%% Cell type:code id: tags:
```
python
df_surveysspecie
[
'
weight
'
]
=
df_surveysspecie
[
'
weight
'
].
fillna
(
0
)
```
%% Cell type:code id: tags:
```
python
plt
.
pyplot
.
scatter
(
df_surveysspecie
[
'
taxa
'
](
skipna
=
True
),
df_surveysspecie
[
'
weight
'
])
```
%% Cell type:code id: tags:
```
python
df_surveysspecie
[
'
taxa
'
].
hist
()
```
%% Cell type:code id: tags:
```
python
df_surveysspecie
[
'
taxa
'
].
unique
()
```
%% Cell type:code id: tags:
```
python
df_surveysspecie
[
df_surveysspecie
[
'
weight
'
]
>
0
][
'
weight
'
].
max
()
```
%% Cell type:code id: tags:
```
python
df_weight_vs_taxa
=
pd
.
concat
([
df_surveysspecie
[
df_surveysspecie
[
'
weight
'
]
>
0
][
'
weight
'
],
df_surveysspecie
[
df_surveysspecie
[
'
weight
'
]
>
0
][
'
taxa
'
]],
axis
=
1
)
f
,
ax
=
plt
.
subplots
()
fig
```
This diff is collapsed.
Click to expand it.
data-used/analisis.csv
+
1
−
1
View file @
7bfd4af7
...
@@ -30,4 +30,4 @@ tur08,Francia,9,15.5
...
@@ -30,4 +30,4 @@ tur08,Francia,9,15.5
tur09,Francia,10,17
tur09,Francia,10,17
tur10,Francia,5,11.5
tur10,Francia,5,11.5
tur11,Francia,20,26
tur11,Francia,20,26
tur12,Francia,27,43.5
tur12,Francia,27,43.5
\ No newline at end of file
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