Professional Status Activity
とProfessional Status Activity Type
の数値のデータフレーム値を置き換えようとしていますが、その前にmapの各値がthrの小文字の値と比較されていることを確認しますDF列Professionalステータスアクティビティ最初の行に= Full Time Employed
は、それを小文字と比較した場合例えば :データフレームと、マップ内の値がない場合は、だから、これは私が必要とするロジックです= 2Pandasが小文字に置き換えられます。その他のオプション[Python]
mapping_dict = {
"Professional Status Activity": {
"full time employed": 1,
"pension": 1,
"student": 2,
"part time employed": 2,
"other": 2,
"unemployed": 3
},
"Professional Status Activity Type":{
"civil servant": 1,
"judge": 1,
"army officer": 1,
"worker": 2,
"insurance officer": 2,
"notary": 2,
"lawyer": 2,
"consultant": 3,
"chief l": 3
}
}
df = df.replace(mapping_dict)
価値を置きます地図オブジェクトにフルタイムで採用されているので、結果は地図から1になります。 df列のプロフェッショナルステータスアクティビティの最初の行= Something not have in map
の結果は2
[最小、完全で、検証可能な例](https://stackoverflow.com/help/mcve)を提供できますか? – Tbaki