temporal/ctrl_2/ej_01/ejercicio_01.ipynb
2024-06-30 13:47:43 -04:00

244 lines
8.0 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"id": "22f35792-a38d-49bf-8e02-c299271055cb",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" Order_ID Product Category Amount Date Country\n",
"count 213.000000 213 213 213 213 213\n",
"unique NaN 7 2 213 150 7\n",
"top NaN Banana Fruit $4'270 16-01-16 United States\n",
"freq NaN 71 146 1 4 57\n",
"mean 107.000000 NaN NaN NaN NaN NaN\n",
"std 61.631972 NaN NaN NaN NaN NaN\n",
"min 1.000000 NaN NaN NaN NaN NaN\n",
"25% 54.000000 NaN NaN NaN NaN NaN\n",
"50% 107.000000 NaN NaN NaN NaN NaN\n",
"75% 160.000000 NaN NaN NaN NaN NaN\n",
"max 213.000000 NaN NaN NaN NaN NaN\n"
]
}
],
"source": [
"import pandas as pd\n",
"\n",
"df = pd.read_csv('venta_verduras_y_frutas.csv')\n",
"\n",
"print(df.describe(include='all'))"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "ec8937dc-0605-4dcc-9f7c-faeac54c05d9",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" Order_ID Product Category Amount Date Country\n",
"0 1 Carrots Vegetables $4'270 06-01-16 United States\n",
"1 2 Broccoli Vegetables $8'239 07-01-16 United Kingdom\n",
"2 3 Banana Fruit $617 08-01-16 United States\n",
"3 4 Banana Fruit $8'384 10-01-16 Canada\n",
"4 5 Beans Vegetables $2'626 10-01-16 Germany\n",
"5 6 Orange Fruit $3'610 11-01-16 United States\n",
"6 7 Broccoli Vegetables $9'062 11-01-16 Australia\n",
"7 8 Banana Fruit $6'906 16-01-16 New Zealand\n",
"8 9 Apple Fruit $2'417 16-01-16 France\n",
"9 10 Apple Fruit $7'431 16-01-16 Canada\n"
]
}
],
"source": [
"print(df.head(10))"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "598245c7-d0c7-4173-aaf8-e7511d4b10a9",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" Order_ID Product Category Amount Date Country\n",
"203 204 Orange Fruit $2'782 20-12-16 United Kingdom\n",
"204 205 Apple Fruit $2'455 20-12-16 Canada\n",
"205 206 Apple Fruit $4'512 22-12-16 New Zealand\n",
"206 207 Apple Fruit $8'752 22-12-16 Germany\n",
"207 208 Carrots Vegetables $9'127 25-12-16 United States\n",
"208 209 Apple Fruit $1'777 28-12-16 France\n",
"209 210 Beans Vegetables $680 28-12-16 France\n",
"210 211 Orange Fruit $958 29-12-16 United States\n",
"211 212 Carrots Vegetables $2'613 29-12-16 Australia\n",
"212 213 Carrots Vegetables $339 30-12-16 Australia\n"
]
}
],
"source": [
"print(df.tail(10))"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "64be6624-d703-4ade-9eb6-c55f9e379250",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" Category Amount\n",
"0 Vegetables $4'270\n",
"1 Vegetables $8'239\n",
"2 Fruit $617\n",
"3 Fruit $8'384\n",
"4 Vegetables $2'626\n",
".. ... ...\n",
"208 Fruit $1'777\n",
"209 Vegetables $680\n",
"210 Fruit $958\n",
"211 Vegetables $2'613\n",
"212 Vegetables $339\n",
"\n",
"[213 rows x 2 columns]\n"
]
}
],
"source": [
"parcial_data = df[['Category','Amount']]\n",
"print(parcial_data)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "1511d979-3831-4f84-ac77-73d0f0958497",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Index(['Order_ID', 'Product', 'Category', 'Amount', 'Date', 'Country'], dtype='object')\n"
]
}
],
"source": [
"columnas = df.columns\n",
"print(columnas)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "6a97d112-05f8-44f2-8ca9-0bded4b73283",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" Order_ID Product Category Amount Date Country\n",
"2 3 Banana Fruit $617 08-01-16 United States\n",
"3 4 Banana Fruit $8'384 10-01-16 Canada\n",
"5 6 Orange Fruit $3'610 11-01-16 United States\n",
"7 8 Banana Fruit $6'906 16-01-16 New Zealand\n",
"8 9 Apple Fruit $2'417 16-01-16 France\n",
".. ... ... ... ... ... ...\n",
"204 205 Apple Fruit $2'455 20-12-16 Canada\n",
"205 206 Apple Fruit $4'512 22-12-16 New Zealand\n",
"206 207 Apple Fruit $8'752 22-12-16 Germany\n",
"208 209 Apple Fruit $1'777 28-12-16 France\n",
"210 211 Orange Fruit $958 29-12-16 United States\n",
"\n",
"[146 rows x 6 columns]\n"
]
}
],
"source": [
"frutas = df[df['Category']=='Fruit']\n",
"print(frutas)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "e49afb79-1749-421a-bd63-919bc1c74bcf",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" Order_ID \n",
" count mean std min 25% 50% 75% max\n",
"Category \n",
"Fruit 146.0 107.239726 60.488734 3.0 56.75 106.0 158.75 211.0\n",
"Vegetables 67.0 106.477612 64.516467 1.0 47.50 110.0 161.50 213.0\n"
]
}
],
"source": [
"grupos = df.groupby('Category')\n",
"print(grupos.describe())"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "afe9d318-f0f9-4214-8935-9f6c6214f5e8",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'inspect' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[20], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m#frutas = df.filter()\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m help(\u001b[43minspect\u001b[49m)\n",
"\u001b[0;31mNameError\u001b[0m: name 'inspect' is not defined"
]
}
],
"source": [
"#frutas = df.filter()\n",
"help(inspect)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.12.4"
}
},
"nbformat": 4,
"nbformat_minor": 5
}