-
-
Notifications
You must be signed in to change notification settings - Fork 17.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DataFrame constructor acts differently with lists and Numpy arrays #9131
Comments
if you are starting with a python structure (a list), I am not sure of the issue here. Why would you convert to a numpy array first? what are you trying to do? |
I'm getting data from a JSON response. This is a list of nested dictionaries which first need to be flatten. I could do this:
but I think it's better for performance issue to work with numpy arrays
and I build a DataFrame Here is my
|
@scls19fr I would encourage you to profile your code to test your theories about performance (IPython makes this easy with the To give a little more context on the design here, pandas does some inference steps about how to format the data only when it is provided as a list for this exact reason, because it's usually not a good idea to nest dictionaries in numpy arrays. |
Thanks. I understand your point of view. But is there any tip to create columns from dict keys automatically ? |
@scls19fr you might want to have a look here: http://pandas.pydata.org/pandas-docs/stable/io.html#normalization closing as a usage issue |
Hello,
I noticed a strange behavior when a Numpy array is given to a Pandas DataFrame constructor.
I don't know really if it should be considered as an issue (or a feature)...
but anyway a tip to fix this will be nice.
but with Numpy array
I was expecting same results. I was expecting a DataFrame with columns named 'a', 'b', 'c' like
when I feed DataFrame with a standard list.
I can "fix" this using
I don't think that
pd.DataFrame(list(arr))
is a nice idea... (with a big array it will be probably very long)Any idea ?
Kind regards
The text was updated successfully, but these errors were encountered: