🎥 Práctica grabada
🎥 Recorded practice
Este material acompaña la práctica grabada paso a paso. Puedes ver el video en YouTube y usar esta guía para copiar los scripts mientras avanzas.
Ver práctica en YouTubeThis material supports the step-by-step recorded practice. You can watch the video on YouTube and use this guide to copy the scripts as you move forward.
Watch practice on YouTubeGuion de apertura
Opening script
“Tengo un archivo Excel basado en Northwind. No tengo nada preparado en Python. Vamos a subirlo a Google Colab, explorarlo y empezar a responder preguntas de negocio.”
“I have an Excel file based on Northwind. I do not have anything prepared in Python. We are going to upload it to Google Colab, explore it, and start answering business questions.”
Antes de comenzar — aviso importante
Before starting — important warning
1. Subir el archivo Excel a ColabUpload the Excel file to Colab
from google.colab import files
uploaded = files.upload()
Luego selecciona el archivo: Northwinds.xlsx.
Then select the file: Northwinds.xlsx.
2. Verificar que el archivo llegóVerify that the file was uploaded
import os
os.listdir()
“En el mundo real no asumimos que el archivo está listo. Primero validamos.”
“In the real world, we do not assume the file is ready. First, we validate.”
3. Leer el ExcelRead the Excel file
import pandas as pd
df = pd.read_excel("Northwinds.xlsx")
df.head()
4. Listar columnasList columns
for col in df.columns:
print(col)
5. Revisar cantidad de filas y columnasCheck rows and columns
df.shape
6. Calcular SalesCalculate Sales
df["Sales"] = (
df["Quantity"]
* df["UnitPrice"]
* (1 - df["Discount"])
)
df[["CompanyName", "ProductName", "UnitPrice", "Quantity", "Discount", "Sales"]].head()
“Ahora no estamos aprendiendo sintaxis. Estamos creando una métrica real de ventas.”
“Now we are not learning syntax. We are creating a real sales metric.”
7. Top 10 ventasTop 10 sales
“Aquí ya empezamos a pensar como analistas: no miramos todas las filas; buscamos las transacciones que más pesan en el negocio.”
“Here we start thinking like analysts: we do not look at every row; we look for the transactions that matter the most to the business.”
top10_sales = (
df[[
"CompanyName",
"ProductName",
"UnitPrice",
"Quantity",
"Discount",
"Sales"
]]
.sort_values(by="Sales", ascending=False)
.head(10)
)
top10_sales
8. Top 10 ventas con formato profesionalTop 10 sales with professional formatting
top10_sales.style.format({
"UnitPrice": "${:,.2f}",
"Discount": "{:.0%}",
"Sales": "${:,.2f}"
}).set_properties(
subset=["CompanyName", "ProductName"],
**{"text-align": "left"}
).set_properties(
subset=["UnitPrice", "Quantity", "Discount", "Sales"],
**{"text-align": "right"}
)
9. Ventas totales por compañíaTotal sales by company
sales_by_company = (
df.groupby("CompanyName")["Sales"]
.sum()
.reset_index()
.sort_values(by="Sales", ascending=False)
)
sales_by_company.head(10)
10. Mostrar Sales como currencyDisplay Sales as currency
sales_by_company.style.format({
"Sales": "${:,.2f}"
}).set_properties(
subset=["CompanyName"],
**{"text-align": "left"}
).set_properties(
subset=["Sales"],
**{"text-align": "right"}
)
11. Bottom 5 compañías por ventasBottom 5 companies by sales
bottom5_sales = (
sales_by_company
.sort_values(by="Sales", ascending=True)
.head(5)
)
bottom5_sales.style.format({
"Sales": "${:,.2f}"
})
12. Promedio de ventas por compañíaAverage sales by company
average_sales = sales_by_company["Sales"].mean()
print(f"Average Sales per Company: ${average_sales:,.2f}")
13. Desviación estándar por compañíaStandard deviation by company
avg_sales = sales_by_company["Sales"].mean()
std_sales = sales_by_company["Sales"].std()
lower_limit = avg_sales - std_sales
upper_limit = avg_sales + std_sales
print(f"Average Sales: ${avg_sales:,.2f}")
print(f"Standard Deviation: ${std_sales:,.2f}")
print(f"Typical Range: ${lower_limit:,.2f} to ${upper_limit:,.2f}")
14. Ventas totales por productoTotal sales by product
sales_by_product = (
df.groupby("ProductName")["Sales"]
.sum()
.reset_index()
.sort_values(by="Sales", ascending=False)
)
sales_by_product.head(10)
15. Promedio y desviación estándar por productoAverage and standard deviation by product
avg_product_sales = sales_by_product["Sales"].mean()
std_product_sales = sales_by_product["Sales"].std()
lower_product_limit = avg_product_sales - std_product_sales
upper_product_limit = avg_product_sales + std_product_sales
print(f"Average Sales per Product: ${avg_product_sales:,.2f}")
print(f"Standard Deviation: ${std_product_sales:,.2f}")
print(f"Typical Range: ${lower_product_limit:,.2f} to ${upper_product_limit:,.2f}")
Cierre sugerido
Suggested closing
“En este primer topic no memorizamos Python. Tomamos un Excel real, lo subimos a Colab, creamos una métrica de ventas y respondimos preguntas de negocio. Eso es Learning by Doing.”
“In this first topic, we did not memorize Python. We took a real Excel file, uploaded it to Colab, created a sales metric, and answered business questions. That is Learning by Doing.”