I have a Numpy array as a list of lists with dimension of n by 4 (row, column). I am trying to separate the data from each individual list instance into four separate arrays each containing all the information from a single column so I can add it to a pandas data frame. From this:
[[126 188 166 1]
[111 173 149 1]
[ 81 119 123 2]
[ 83 122 124 2]
[ 84 122 124 2]
[255 255 255 3]
[255 255 255 3]
[255 255 255 3]]
To this:
bBand = [126,111,81,...,255]
gBand = [188,173,119,...,255]
rBand = [166,149,123,...,255]
class = [1,1,2,...,3]
Current Code:
MasterList = np.arrray([[126, 188, 166, 1],[111, 173, 149, 1],[ 81, 119, 123, 2],[ 83, 122, 124, 2],[ 84, 122, 124, 2],[255, 255, 255, 3],[255, 255, 255, 3],[255, 255, 255, 3]])
print(MasterList)
columns = ["bBand","gBand","rBand","class"]
df = pd.DataFrame(MasterList.reshape(-1, len(MasterList)),columns=columns)
pd.DataFrame(MasterList, columns=columns)would have worked. Why do you need the separation, and why the reshape?