df = pd.DataFrame([["A", 1], ["B", 2], ["C", 3], ["D", 4], ["E", 5]])
df2 = pd.DataFrame({"row1": [1, 2, 3], "row2": [11, 12, 13]})
noun_df["word"]
noun_df[0:3:1] # スライス表記
noun_df["emotion"].value_counts()
tmp_df | A | B |
---|---|---|
one | a1 | b1 |
two | a2 | b2 |
three | a3 | b3 |
tmp_df["one":"one"]
tmp_df.loc["one":"three"]
tmp_df.loc[tmp_df["A"] == "a3"]
tmp_df.loc[(tmp_df["A"] == "a3") | (tmp_df["B" == 1])]
tmp_df.iloc[1,1]
tmp_df.at["three", "A"]
tmp_df.loc["six"].at["B"]
tmp_df.iat[0,1]
df["hoge"]
とかはこっちdf.loc
とかはこっちtmp_df["A"] = tmp_df["A"].str.replace("a", "z")
(ちなみにこのstrはpandas.core.strings.accessor.StringMethods
であり,str型ではない)
# ignore_index=Trueとすると元のインデックスを無視して新しく数字を振り直す.
df = pd.concat([tmp_df, tmp_df], ignore_index=True)