Reputation: 3106
Consider the following code:
import numpy as np
import pandas as pd
a = np.array([[1,2],[3,4],[5,6],[7,8]])
k = pd.DataFrame({"a": list(a)})
I'd like to retrieve the original numpy array. However, when I call .values
I get something different.
How can I get the original numpy array, that looks like this:
array([[1, 2],
[3, 4],
[5, 6],
[7, 8]])
?
Thank you.
Upvotes: 2
Views: 184
Reputation: 862601
You can create nested lists and convert to 2d array:
np.array(k['a'].tolist())
Upvotes: 2