pandas 對一列作變換,手工版的labelEncoder 和 labelEncoder

import pandas as pd df = pd.DataFrame({"key": ["aa", "bb", "cc"]}) dict = {"aa": 1, "bb": 3, "cc": 2} df_map = df["key"].map(dict) print("raw:\n", df.head()) print("mapped:\n", df_map)   raw: key
相關文章
相關標籤/搜索