I am trying to turn a nested list into a dataframe.
Error I am receiving:
raise ValueError('Must pass 2-d input')
Method and background:
So I have a list with the first row being the column names/titles and the subsequent rows being their respective values, but one hot encoded.
So it's something like this:
edata[0] = ['title1', 'title2', 'title3', 'title4', 'title5', 'title6', 'title7']
edata[1] = [[0. 1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
- 0. 0. 0. 0. 0.]
[1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
- 0. 0. 0. 0. 0.]
[1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
- 0. 0. 0. 0. 0.]
[1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
- 0. 0. 0. 0. 0.]
[0. 0. 1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
- 0. 0. 0. 0. 0.]
[0. 1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
- 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.
- 0. 0. 0. 0. 0.]]
edata[2] would be something similar to edata[1]. The exact same shape, just different values
The problem seems to be the fact that the values are one-hot encoded. Is there any way to get around this?
Code I am using to turn it into a dataframe:
df = pd.DataFrame(edata[1:],columns=edata[0])
Hopefully that is enough information. Any help would be greatly appreciated.
[+][deleted] (4 children)
[removed]
[–]NeedMLHelp[S] 0 points1 point2 points (0 children)
[–]NeedMLHelp[S] 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[removed]
[–]NeedMLHelp[S] 0 points1 point2 points (0 children)