I have a data-frame of size (140000,22) dimensions.
i have to create 2d array of equal dimensions to pass it into convolution neural network .
Can you please guide how to transform on this dataframe
I have a data-frame of size (140000,22) dimensions.
i have to create 2d array of equal dimensions to pass it into convolution neural network .
Can you please guide how to transform on this dataframe
Edit: If by 'equal' dimensions you mean it should be a square array, this is not possible, since 140000*22 is not a square number. However, in general you don't need a square array to feed data into a CNN, but this of course depends on your specific CNN.
Old answer:
You just need to call .values
on the DataFrame.
If for example your dataframe is called df
, then you can pass df.values
to your convolutional neural network.
Use arr = df.to_numpy()
See: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_numpy.html
It will create a 2d array where each row is the inner array.
[[row1],
[row2],
[row3]...
[row n]]
To turn it into a 2d array where each column is the inner array, use transpose:
arr = np.transpose(arr)
[[all_data_in_col_1],
[all_data_in_col_2],...
[all_data_in_col_n]]
© 2022 - 2024 — McMap. All rights reserved.