<jupyter_start><jupyter_text>Membaca dari File<jupyter_code>df = pd.read_csv("data/cereal.csv")
df.head(n=10)
df.tail()
df.columns
df.index
df.shape
illustration.nomenklatur<jupyter_output><empty_output><jupyter_text>Get Columns and Row<jupyter_code>df["name"].head()
df.calories.head()
df[["name","mfr","type","rating"]][5:10]<jupyter_output><empty_output><jupyter_text>Slicing with .loc and .iloc<jupyter_code>df.loc[5:10,"fat":"carbo"] #loc itu pakai nama dai baris dan kolom -> semua inclusive
df.iloc[5:10,3:7] #iloc itu pakai index dari baris dan kolom --> ada exclusive
df.loc[5:10,["name","mfr","rating"]]<jupyter_output><empty_output><jupyter_text>Biasakan kalau ada index, langsung dijadikan index<jupyter_code>df = pd.read_csv("data/cereal.csv", index_col="name")
df.head()
df.shape<jupyter_output><empty_output><jupyter_text>DataFrame Summary  Statistics<jupyter_code>df.describe()
df.corr()<jupyter_output><empty_output><jupyter_text>Count<jupyter_code>df.mfr.value_counts()<jupyter_output><empty_output><jupyter_text>Unique<jupyter_code>df.mfr.unique()
df.nunique()<jupyter_output><empty_output><jupyter_text>NaN Value<jupyter_code>df.isna().sum()
df.dropna()
filler = {"carbo": "CARBO", "sugar": "SUGAR", "potass": "POTASS"}
df.fillna(filler).head()
df
df.fillna(df.mean(), inplace=True)
df.isna().sum()<jupyter_output><empty_output><jupyter_text>Save to csv<jupyter_code>df.to_csv("data/cereal_imp.csv", index_label="name") #impute = mengisi data<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17292225201072386, 'fraction_numerical': 0.010723860589812333, 'mean_word_length': 10.84920634920635, 'pattern_counts': {'":': 4, '<': 37, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '461831', 'license': 'MIT', 'n_tokens_mistral': 650, 'n_tokens_neox': 637, 'n_words': 75, 'path': '02 - Pandas Introduction/Part 1 - Pandas Intro.ipynb', 'repo_name': 'iwanevandersyema/supervised_learning', 'size': '1492'}