<jupyter_start><jupyter_text>4-2-1 pandasの概要<jupyter_code>import pandas as pd
ser = pd.Series([10, 20, 30, 40])
ser
df = pd.DataFrame([[10, "a", True],
                  [20, "b", False],
                  [30, "c", False],
                  [40, "d", True]])
df
import numpy as np
df = pd.DataFrame(np.arange(100).reshape((25, 4)))
df
df.head()
df.tail()
df.shape
df = pd.DataFrame(np.arange(6).reshape((3, 2)))
df
df.index = ["01", "02", "03"]
df.columns = ["A", "B"]
df
named_df = pd.DataFrame(np.arange(6).reshape((3, 2)),
                        columns=["A列", "B列"],
                        index=["1行目", "2行目", "3行目"])
named_df
pd.DataFrame({"A列": [0, 2, 4], "B列": [1, 3, 5]})
import numpy as np
import pandas as pd
df = pd.DataFrame(np.arange(12).reshape((4, 3)),
          columns=["A", "B", "C"],
          index=["1行目", "2行目", "3行目", "4行目"])
df
df["A"]
df[["A", "B"]]
df[:2]
df.loc[:, :]
df.loc[:, "A"]
df.loc[:, ["A", "B"]]
df.loc["1行目", :]
df.loc[["1行目", "3行目"], :]
df.loc[["1行目"], ["A", "C"]]
df.iloc[1, 1]
df.iloc[1:, 1]
df.iloc[1:, :2]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.27012025901942643, 'fraction_numerical': 0.060129509713228495, 'mean_word_length': 3.0074074074074075, 'pattern_counts': {'":': 2, '<': 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': '399574', 'license': 'MIT', 'n_tokens_mistral': 527, 'n_tokens_neox': 496, 'n_words': 106, 'path': 'ds-newtextbook-python/notebooks/4-2-1-pandas-about.ipynb', 'repo_name': 'sota0121/datascience-exercise', 'size': '1081'}