<jupyter_start><jupyter_text>1) Data Loading<jupyter_code>people = {
    "first": ["yonathan", "efrem", "daniel"],
    "last": ["cherkos", "muse", "cherkos"],
    "email": ["<EMAIL>", "<EMAIL>", "<EMAIL>"]
}
df = pd.DataFrame(people)
df<jupyter_output><empty_output><jupyter_text>2) Selecting Rows and Columns<jupyter_code>df.email
df["email"]
df.iloc[0]
df.loc[0]
df.loc[1, ["last", "email"]]<jupyter_output><empty_output><jupyter_text>3) Set, Reset, and Use Indexes<jupyter_code>df.set_index("email")
df
df.set_index("email", inplace=True)
df
df.reset_index(inplace=True)
df<jupyter_output><empty_output><jupyter_text>4) Using Conditionals to Filter Rows and Columns<jupyter_code>filt = (df["last"] == "cherkos")
df[filt]
df.loc[filt, "email"]
df.loc[~filt]<jupyter_output><empty_output><jupyter_text>5) Updating Rows and Columns - Modifying Data Within DataFrames<jupyter_code>df.columns
df.rename(columns={'first': 'firstname', 'last': 'lastname'}, inplace=True)
df
filt = (df["lastname"] == "cherkos")
df.loc[filt, "lastname"] = "w/cherkos"
df
def update_firstname(firstname):
    return firstname.capitalize()
df["firstname"] = df["firstname"].apply(update_firstname)
df
df["lastname"].replace({"w/cherkos": "cherkos"}, inplace=True)
df<jupyter_output><empty_output><jupyter_text>6) Add Remove Rows and Columns From DataFrames<jupyter_code>df["first"] + " " + df["last"]
df["fullname"] = df["first"] + " " + df["last"]
df
df.drop(columns=["first", "last"], inplace=True)
df
df["fullname"].str.split(" ", expand=True)
df[["first", "last"]] = df["fullname"].str.split(" ", expand=True)
df
df = df.append({"first": "eleny"}, ignore_index=True)
df
df = df.drop(index=3)
df<jupyter_output><empty_output><jupyter_text>7) Sorting Data<jupyter_code>df.sort_values(by="last", ascending=True)
df.sort_values(by=["last", "first"], ascending=[True, False], inplace=True)
df<jupyter_output><empty_output><jupyter_text>8) Grouping and Aggregating  9) Cleaning Data - Casting Datatypes and Handling Missing Values<jupyter_code>people = {
    "first": ["yonathan", "efrem", "daniel", np.nan, np.nan, "NA"],
    "last": ["cherkos", "muse", "cherkos", None, np.nan, "Missing"],
    "email": ["<EMAIL>", "<EMAIL>", None, None, "<EMAIL>", "Missing"]
}
df = pd.DataFrame(people)
df
df.dropna()
df.dropna(axis="index", how="all")
df.dropna(axis="index", how="all", subset=["email"])
df.replace({"NA": np.nan, "Missing": np.nan, None: np.nan}, inplace=True)
df
df.dropna(axis="index", how="all")
df["age"] = [24, 22, 25, 22, 21, 30]
df
df["age"].mean()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2101364522417154, 'fraction_numerical': 0.009746588693957114, 'mean_word_length': 7.940766550522648, 'pattern_counts': {'":': 10, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '204369', 'license': 'MIT', 'n_tokens_mistral': 1044, 'n_tokens_neox': 1026, 'n_words': 185, 'path': 'pandas/Snippets.ipynb', 'repo_name': 'yonycherkos/data_analysis', 'size': '2649'}