Issue
I am implementing a classification machine learning algorithm. The dataset contains numerical as well as nominal values in no specific order. The numeric and nominal values are in separate columns but these columns are scattered throughout the dataset. Also, the columns/ attributes are exactly 279 in number. How can I reorder or sort the dataset to have numerical valued columns on one side and nominal valued columns on the other side of the dataset? P.S. I need to sort the columns so I can implement standardization in this way:
from sklearn.preprocessing import StandardScaler
sc = StandardScaler()
x_train[:, 49: ] = sc.fit_transform(x_train[:, 49: ])
x_test[:, 49: ] = sc.transform(x_test[:, 49: ])
The link to the dataset is provided below for more information. https://archive.ics.uci.edu/ml/datasets/Arrhythmia
Solution
Select number columns and object (string) columns and then concat them side by side:
df1 = pd.concat((df.select_dtypes('number'), df.select_dtypes('object')), axis=1)
Answered By - Stef
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.