我有一个类别数据的DataFrame看起来像这样:
original looking
我正在使用pd.get_dummies获取此数据的虚拟变量:
dummy_field_t = ['Partner','Dependents','MultipleLines','InternetService',
'OnlineSecurity','OnlineBackup','DeviceProtection','TechSupport',
'StreamingMovies','StreamingTV','Contract','PaperlessBilling','PaymentMethod']
X_dummy =pd.Data
for feature in dummy_field_t:
dummies = pd.get_dummies( X_train.loc[:, feature], prefix=feature )
X_dummy = pd.concat( [X_dummy, dummies], axis = 1 )
奇怪的是,我在X_dummy中得到了一些NA值,如下所示:
enter image description here
为什么该方法对某些行有效而对某些行无效?