-
-
Save amankharwal/df630e134fc390067246f668b07dbafb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dataframe_to_arrays(dataframe): | |
# Make a copy of the original dataframe | |
dataframe1 = dataframe.copy(deep=True) | |
# Convert non-numeric categorical columns to numbers | |
for col in categorical_cols: | |
dataframe1[col] = dataframe1[col].astype('category').cat.codes | |
# Extract input & outupts as numpy arrays | |
inputs_array = dataframe1[input_cols].to_numpy() | |
targets_array = dataframe1[output_cols].to_numpy() | |
return inputs_array, targets_array | |
inputs_array, targets_array = dataframe_to_arrays(dataframe) | |
inputs_array, targets_array |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment