¡Bienvenidos a esta sesión! Hoy vamos a revisar el tema de las advertencias en Pandas y cómo estas afectan tu análisis de datos. Aprenderemos a interpretar los mensajes de alerta que surgen en tu libreta de Jupyter y a manejarlos de manera efectiva.
Las advertencias en Pandas son más que simples notificaciones; son indicadores cruciales que pueden tener un impacto significativo en tu análisis. Estos mensajes no solo sirven para señalar problemas menores, sino que también son herramientas valiosas que te orientan para identificar posibles inconvenientes y perfeccionar tu código.
Es importante aprender a identificar advertencias relacionadas con funciones que están quedando obsoletas o que han experimentado cambios en su sintaxis. Esto te permitirá mantener tu código al día y evitar posibles errores en versiones futuras de Pandas.
# pip uninstall pyarrow --y
import pandas as pd
/var/folders/2z/fh3yv7r50rxgy804jm3f7b0c0000gn/T/ipykernel_62846/4080736814.py:1: DeprecationWarning:
Pyarrow will become a required dependency of pandas in the next major release of pandas (pandas 3.0),
(to allow more performant data types, such as the Arrow string type, and better interoperability with other libraries)
but was not found to be installed on your system.
If this would cause problems for you,
please provide us feedback at https://github.com/pandas-dev/pandas/issues/54466
import pandas as pd
f ="../data/Cuernavaca_Enero_comas.csv"cuerna = pd.read_csv(f,index_col=0,parse_dates=True)cuerna
/var/folders/2z/fh3yv7r50rxgy804jm3f7b0c0000gn/T/ipykernel_62846/3724519935.py:1: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
cuerna_1dia["To"] = 10
/var/folders/2z/fh3yv7r50rxgy804jm3f7b0c0000gn/T/ipykernel_62846/2653515496.py:1: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise an error in a future version of pandas. Value 'a' has dtype incompatible with int64, please explicitly cast to a compatible dtype first.
cuerna.loc[cuerna.To>19,"RH"] = 'a'