I was wondering how I would be able to convert my binned dataframe to a binned numpy array that I can use in sklearn's PCA.
Here's my code so far (x is my original unbinned dataframe):
bins=(2,6,10,14,20,26,32,38,44,50,56,62,68,74,80,86,92,98)
binned_data = x.groupby(pd.cut(x.Weight, bins))
I want to convert binned_data to a numpy array. Thanks in advance.
EDIT:
When I try binned_data.values, I receive this error:
AttributeError: Cannot access attribute 'values' of 'DataFrameGroupBy' objects, try using the 'apply' method
binned_data.values?xor some code to generate it.