-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Inconsistent index between plain DataFrame and read_sql DataFrame #48193
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to have the sql smoke test from the original issue as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want this? This seems to be deliberate.
I think the if isn't needed at all, if we want a RangeIndex?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am -1 on this change without deprecation and -0 on this change in general.
data = {1: ["foo"], 2: ["bar"]}
exp = DataFrame(data, columns=["a", "b"])
DataFrame()
These operations create regular Index objects, not a RangeIndex, this change would cause inconsistencies.
You can also see this on the number of tests you had to change for this
ok. I try to search other method. |
Hi @phofl, when I try this.
On current main branch, index type created is not same. Is this expected? |
Can you create an overview of all possible cases and then add it to the issue? We should aim for consistency if we make a change E.g. reading empty csv for example should be consistent too |
Hi @phofl Possible cases of empty dataframe is as follow. I based on documentation
a) using series
b) using list
c) using array
d) based on columns
|
Based on https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html,
The default is RangeIndex when no index provided |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.