What do you want to save?
Add Code snippet
New code examples
-
Python 2022-03-11 12:50:08
remove columns from a dataframe python
# Let df be a dataframe # Let new_df be a dataframe after dropping a column new_df = df.drop(labels='column_name', axis=1) # Or if you don't want to change the name of the dataframe df = df.drop(labels='column_name', axis=1) # Or to remove several colu... Add solution -
Python 2022-03-04 18:20:02
train test split sklearn
from sklearn.model_selection import train_test_split X = df.drop(['target'],axis=1).values # independant features y = df['target'].values # dependant variable # Choose your test size to split between training and testing sets: X_train, X_test, y_t... Add solution -
Python 2022-01-24 08:45:46
get dummies pandas
note: dummies = pd.get_dummies(df[['column_1']], drop_first=True) df = pd.concat([df.drop(['column_1'],axis=1), dummies],axis=1) note:for more that one coloum keep ading in the list dummies = pd.get_dummies(df[['column_1', 'column_2','column_3']], drop... Add solution