I have the following numpy array:
numpy_x.shape
(9982, 26)
numpy_x have 9982 records/observations and 26 columns index. Is this right really?
numpy_x[:]
array([[0.00000000e+00, 9.60000000e-01, 1.00000000e+00, ...,
1.20000000e+00, 6.90000000e-01, 1.17000000e+00],
[1.00000000e+00, 9.60000000e-01, 1.00000000e+00, ...,
1.20000000e+00, 7.00000000e-01, 1.17000000e+00],
[2.00000000e+00, 9.60000000e-01, 1.00000000e+00, ...,
1.20000000e+00, 7.00000000e-01, 1.17000000e+00],
...,
[9.97900000e+03, 6.10920994e-01, 7.58135980e-01, ...,
1.08704204e+00, 7.88187535e-01, 1.23021669e+00],
[9.98000000e+03, 6.10920994e-01, 7.58135980e-01, ...,
1.08704204e+00, 7.88187535e-01, 1.23021669e+00],
[9.98100000e+03, 6.10920994e-01, 7.58135980e-01, ...,
1.08704204e+00, 7.88187535e-01, 1.23021669e+00]])
I want generate a dataframe with numpy_x data, index and columns (index and columns are the same really?), then I proceed to perform the following:
import pandas as pd
pd.DataFrame(data=numpy_x[:], # I want pass the entire numpy array content
index=numpy_x[1:26],
columns=numpy_x[9982:26])
But I get the following error:
/.conda/envs/x/lib/python3.6/site-packages/pandas/core/internals.py in construction_error(tot_items, block_shape, axes, e)
4606 raise ValueError("Empty data passed with indices specified.")
4607 raise ValueError("Shape of passed values is {0}, indices imply {1}".format(
-> 4608 passed, implied))
4609
4610
ValueError: Shape of passed values is (26, 9982), indices imply (0, 25)
How to can I understand what parameters pass on index and columns attributes?
columnsare the columns that you require for your table.indicesare kind of group by value by which the table will be indexed with.