カテゴリの名前を変更し、欠落しているカテゴリをシリーズに追加します。カテゴリの名前を変更し、欠落しているカテゴリをシリーズに追加します。PANDAS
マイコード:
codedCol = bdAu['Bordersite']
print 'pre:'
print codedCol.head(10)
codedCol = codedCol.astype('category')
codedCol = codedCol.cat.set_categories(['a','b','c','d','e','f','g','h','i','j'])
print 'post:'
print codedCol.head(10)
私はこれを行うと、私は結果としてはNaNを取得します。
pre:
0 3
1 3
2 2
3 2
4 3
5 4
6 5
7 3
8 3
9 3
Name: Bordersite, dtype: int64
post:
0 NaN
1 NaN
2 NaN
3 NaN
4 NaN
5 NaN
6 NaN
7 NaN
8 NaN
9 NaN
dtype: category
Categories (10, object): [a, b, c, d, ..., g, h, i, j]
私はここで間違っていますか? :
おかげ Kheeran
あなたの理想的な結果は何ですか? –
私は答えを加えました...助けてくれたら教えてください。 –