<jupyter_start><jupyter_text><jupyter_code>!pip install --upgrade pandas
from google.colab import drive
drive.mount('/content/drive/')<jupyter_output>Drive already mounted at /content/drive/; to attempt to forcibly remount, call drive.mount("/content/drive/", force_remount=True).<jupyter_text>> Link para buscar datasets de pruebas [click aquí](https://datasetsearch.research.google.com/)<jupyter_code>%cd '/content/drive/My Drive/Colab Notebooks/db'
!ls
import pandas as pd
pd.__version__
df_meteorites = pd.read_csv('Meteorite_Landings.csv')
df_meteorites.head(10) #tail() sample()
df_meteorites.shape
df_meteorites.size
pd.options.display.float_format='{:,.1f}'.format
df_meteorites.describe()
df_meteorites.describe(include='all')<jupyter_output><empty_output><jupyter_text>Introducción a las variables categóricas y cómo manejarlas con pandas<jupyter_code>df_meteorites.info()
df_meteorites.dtypes
df_meteorites.convert_dtypes().dtypes
df_meteorites.nunique()
df_meteorites[['fall','nametype']] = df_meteorites[['fall','nametype']].astype('category')
df_meteorites.dtypes
df_meteorites['fall'].unique()
df_meteorites['fall'].value_counts()
df_meteorites['ones'] = 1
df_meteorites
df_meteorites[['fell','found']]= pd.get_dummies(df_meteorites['fall'])
df_meteorites
df_meteorites['year']
pd.to_datetime(
    df_meteorites['year'],
    errors='coerce',
    format='%m/%d/%Y %H:%M:%S %p'
)
df_meteorites['year'] = pd.to_datetime(
    df_meteorites['year'],
    errors='coerce',
    format='%m/%d/%Y %H:%M:%S %p'
)
df_meteorites.convert_dtypes().dtypes
df_meteorites.rename(columns={'mass (g)':'mass'},inplace=True)
df_meteorites
list(df_meteorites)<jupyter_output><empty_output><jupyter_text>Eliminar una columna<jupyter_code>df_meteorites.drop(['ones'], axis=1, inplace=True)
df_meteorites.drop([0,2,4,6])
df2 = df_meteorites.copy(deep=True)
df2.drop(['id'], axis=1,inplace=True)
df2<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16118935837245696, 'fraction_numerical': 0.006781429316640584, 'mean_word_length': 8.937823834196891, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 17, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '324209', 'license': 'MIT', 'n_tokens_mistral': 790, 'n_tokens_neox': 739, 'n_words': 100, 'path': 'manipulacion_datos_pandas/4_datatypes.ipynb', 'repo_name': 'cristian-rincon/escuela-datascience', 'size': '1917'}