python pandas replacing strings in dataframe with numbers

前端 未结 9 1551
名媛妹妹
名媛妹妹 2020-12-08 04:22

Is there anyway to use the mapping function or something better to replace values in an entire dataframe?

I only know how to perform the mapping on series.

I

9条回答
  •  执笔经年
    2020-12-08 04:44

    df.replace(to_replace=['set', 'test'], value=[1, 2]) from @Ishnark comment on accepted answer.

提交回复
热议问题