I have a DataFrame with columns X, Y and value, e.g.:
X | Y | value
------------------
1 | 1 | 56
2 | 1 | 13
3 | 1 | 25
... | ... | ...
1 | 2 | 7
2 | 2 | 18
... | ... | ...
1 | 123 | 91
... | ... | ...
50 | 123 | 32
I need to convert this to DataFrame to a NumPy matrix:
[[56, 13, 25, ...],
[ 7, 18, ...],
...,
[ 91, ... , 32]]
I know I can iterate over each cell of the DataFrame, but that is too slow. What is the effective way of doing this?
Also note: values for some coordinates in DataFrame are missing
df.value.values.reshape(-1,ncols)?{ValueError}total size of new array must be unchanged, probably because the DataFrame contains missing values.