-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: DataFrame.from_xy methods are duplicates #4916
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
Comments
There's an issue for the |
|
Also #3418. Yes |
certainly would take a PR for this, maybe just having it work in 0.13, while warning that its going to be changed in say 0.14 (and I would keep from_records as a separate method), just make it internal, same |
@alefnula yep....its straightforward to do this actually, just add the appropriate keywords to the main DataFrame constructor and delegate if these are passed |
Isn't this in the Python for Data Analysis book? Not great to break examples from something that actually gets people to try pandas. |
I think maybe starting in 0.14 should put deprecations around these (may not actually remove for a while though)....the naming scheme is quite inconsistent with everything else |
I think for 0.16, we should at least just deprecate |
@jreback Merging some of these constructors would be great, and would give the main constructor some additional pieces of functionality. One of those is I'm trying to come up with a ruleset for how the If we had an In [67]: pd.DataFrame({'a':pd.Series([1,2,3])})
Out[67]:
a
0 1
1 2
2 3
In [68]: pd.DataFrame([pd.Series([1,2,3], name='a')])
Out[68]:
0 1 2
a 1 2 3 |
orient only applies / matters for a dict columns / index are what to extract so these are orthogonal personally I think columns / index are actually confusing and one should simply reindex after buy might be difficult to change this |
@jreback thanks; my question more fundamental - why a 0 1 2
a 1 2 3 rather than this: a
0 1
1 2
2 3 |
It's because you're passing in a list of array-likes. e.g. a numpy array In [1]: x = np.array([[1, 2], [3, 4]])
In [2]: x
Out[2]:
array([[1, 2],
[3, 4]])
In [3]: pd.DataFrame(x)
Out[3]:
0 1
0 1 2
1 3 4 |
I see. Cheers @TomAugspurger |
Is this still something people are interested in? from_dict had a kwarg added in 0.23.0 which is much more recent than the OP here |
I think |
Decide what to do with each of these
from_csv
/ change to be exactly like-> DEPR: Deprecate from_csv in favor of read_csv #17812read_csv
This is just a suggestion:
DataFrame
constructor already supports the things thatfrom_dict
andfrom_records
do (from_items
is not supported by the constructor, but maybe it should be?). Alsofrom_csv
does the same thing aspd.read_csv
.Since
There should be one-- and preferably only one --obvious way to do it.
maybe these methods should be removed/deprecated?I know that this would cause backward incompatibility, so maybe just a deprecation warning could be displayed until a future major release that could remove them.
The text was updated successfully, but these errors were encountered: