Skip to content

Commit

Permalink
Laboratorios
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniosql committed Jan 11, 2025
1 parent 04a2d4e commit b867791
Show file tree
Hide file tree
Showing 7 changed files with 3,162 additions and 150 deletions.
93 changes: 89 additions & 4 deletions Notebooks/02_01_Repaso Basico Pandas.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1879,7 +1879,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 24,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -1950,7 +1950,7 @@
"3 camiseta 20 4.2 Ropa"
]
},
"execution_count": 2,
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -1980,7 +1980,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 25,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -2032,7 +2032,7 @@
"1 Ropa 30.0 4.1"
]
},
"execution_count": 3,
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -2041,6 +2041,91 @@
"datos_categorias = df.groupby('categoria_nombre').agg({'precio':'mean', 'rating':'mean'}).reset_index()\n",
"datos_categorias"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>nombre</th>\n",
" <th>precio</th>\n",
" <th>rating</th>\n",
" <th>categoria_nombre</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>ordenador</td>\n",
" <td>1000</td>\n",
" <td>4.5</td>\n",
" <td>Electrónica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>tablet</td>\n",
" <td>500</td>\n",
" <td>4.7</td>\n",
" <td>Electrónica</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>pantalón</td>\n",
" <td>40</td>\n",
" <td>4.0</td>\n",
" <td>Ropa</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>camiseta</td>\n",
" <td>20</td>\n",
" <td>4.2</td>\n",
" <td>Ropa</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" nombre precio rating categoria_nombre\n",
"0 ordenador 1000 4.5 Electrónica\n",
"1 tablet 500 4.7 Electrónica\n",
"2 pantalón 40 4.0 Ropa\n",
"3 camiseta 20 4.2 Ropa"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Para ordenar un dataframe por una columna en concreto, podemos utilizar el método sort_values\n",
"\n",
"df.sort_values(by='precio', ascending=False , inplace=True) ## Ordenamos por precio de mayor a menor\n",
"df.head()"
]
}
],
"metadata": {
Expand Down
4 changes: 2 additions & 2 deletions Notebooks/02_02_Pandas y Bases de Datos.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
" resultado = cursor.fetchall() # Obtenemos todas las filas de la consulta\n",
" cursor.close() \n",
" cnx.close()\n",
"except mysql.connector.Error as err:\n",
" print(\"Error conectando a la base de datos \" + err)\n",
"except :\n",
" print(\"Error conectando a la base de datos \")\n",
" \n"
]
},
Expand Down
13 changes: 10 additions & 3 deletions Notebooks/03_01_Nulos y repetidos.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@
]
},
"execution_count": 1,
"metadata": {
"tags": []
},
"metadata": {},
"output_type": "execute_result"
}
],
Expand All @@ -127,6 +125,15 @@
"#La función StringIO solo se usa para facilitar la demostración para simular que tenemos un fichero real."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 2,
Expand Down
4 changes: 2 additions & 2 deletions Notebooks/04_02_Codificacion de Variables.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1969,7 +1969,7 @@
"toc_visible": true
},
"kernelspec": {
"display_name": "entornoIFFE",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -1983,7 +1983,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.1"
"version": "3.12.6"
}
},
"nbformat": 4,
Expand Down
139 changes: 0 additions & 139 deletions Notebooks/Ejercicio 01.ipynb

This file was deleted.

Loading

0 comments on commit b867791

Please sign in to comment.