Feature Type
-
[ ] Adding new functionality to pandas
-
[X] Changing existing functionality in pandas
-
[ ] Removing existing functionality in pandas
Problem Description
The following code does not work:
pd.DataFrame(data=[1,2,3], columns=["a", "b", "c"], index=[0])
but it should be quite easy to infer that the list must be intended as a row since both columns
and index
arguments are set.
Feature Description
Provide the possibility to initialize a DataFrame with a plain list (or in general 1-D structures) when both columns
and index
arguments are specified. Optionally, provide an additional argument (eg: direction
with possible values index
and columns
) that specifies if the 1-D structure must fill the DataFrame by row or by column.
Alternative Solutions
A working solution is:
pd.DataFrame.from_records([[1,2,3]], columns=["a", "b", "c"])
But is sounds weird to me that the code in the Problem Description section does not work.
Additional Context
No response
Comment From: lucaslarios
This issue still relevant?
Comment From: lucaslarios
Take it
Comment From: tantardini
Yes it's still relevant for me, thank you! Why your merge request is closed?
Comment From: attack68
This feature request does not seem to have gained much traction with core devs. Im -1 on expanding the API for DataFrame construction. It creates more maintenance and I think the input method above Is easily converted into a form that is already parsed to the required DataFrame.
Comment From: mroeschke
I would be -1 here as well. I think it's more explicit and less error having "infer" the broadcasting of one of the axis if the shapes are mismatched.
Since there hasn't been much other support from other core devs on this feature, closing.