<jupyter_start><jupyter_text>Tutorial 6: Important Methods in Pandas<jupyter_code>import pandas as pd
import numpy as np
s=pd.Series([1,2,3,4],
            index=["a","b","c","d"])
s
s["a"]
s2=s.reindex(["b","d","a","c","e"])
s2
s3=pd.Series(["blue","yellow","purple"],
             index=[0,2,4])
s3
s3.reindex(range(6),method="ffill")
df=pd.DataFrame(np.arange(9).reshape(3,3),
                index=["a","c","d"],
                columns=["Tim","Tom","Kate"])
df
df2=df.reindex(["d","c","b","a"])
df2
names=["Kate","Tim","Tom"]
df.reindex(columns=names)
df.loc[["c","d","a"]]
s=pd.Series(np.arange(5.),
            index=["a","b","c","d","e"])
s
new_s=s.drop("b")
new_s
s.drop(["c","d"])
data=pd.DataFrame(np.arange(16).reshape(4,4),
                  index=["Kate","Tim",
                         "Tom","Alex"],
                  columns=list("ABCD"))
data
data.drop(["Kate","Tim"])
data.drop("A",axis=1)
data.drop("Kate",axis=0)
data
data.mean(axis="index")
data.mean(axis="columns")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2730844793713163, 'fraction_numerical': 0.025540275049115914, 'mean_word_length': 4.044554455445544, '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': '492788', 'license': 'MIT', 'n_tokens_mistral': 431, 'n_tokens_neox': 413, 'n_words': 49, 'path': 'jupyter/pandas-tut/06-Important Methods.ipynb', 'repo_name': 'Sesughter01/ds-march-univel', 'size': '1018'}