<jupyter_start><jupyter_text>Missing DataLet's show a few convenient methods to deal with Missing Data in pandas:<jupyter_code>import numpy as np
import pandas as pd
df = pd.DataFrame({'A':[1,2,np.nan],    # Using dicts whith natural key:value pairs to generate df. For
                  'B':[5,np.nan,np.nan],  # list you would need two, one for COL headers and one for COL
                  'C':[1,2,3]}, index=['R1','R2','R3']) # values.
df.index.names = ['ID']
df
df.dropna() # Drops any ROWS with one or more NaN values, because it's AXIS arg is defaulting to 0.
df.dropna(axis=1)   # Drops any COLS with one or more NaN values
df.dropna(thresh=2)   # Drops rows with less than 2 none-NaN values
df.dropna(axis=1, thresh=2) # Drops cols with less than 2 none-NaN values
df.fillna(value='FILL VALUE')   # Fills in NaN values with the value specified in its value arg
df['A'].fillna(value=df['A'].mean())  # Fill NaN values in col A, with the mean of that col. and return it as a series.<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11960784313725491, 'fraction_numerical': 0.01568627450980392, 'mean_word_length': 3.838862559241706, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '290670', 'license': 'MIT', 'n_tokens_mistral': 362, 'n_tokens_neox': 342, 'n_words': 133, 'path': 'Python/data_science/data_analysis/03-Python-for-Data-Analysis-Pandas/04-Missing Data.ipynb', 'repo_name': 'Kenneth-Macharia/Learning', 'size': '1020'}