-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
SQL: add index_label keyword to to_sql #6642
SQL: add index_label keyword to to_sql #6642
Conversation
why don't you just have index accept a string / list / True True means use the index name (raise if it is None) false / none are don't store index instead of adding another kw |
I did that for consistency with |
ok then! |
should think about what to do if u have an unnamed column (I know you are defaulting it) but maybe should warn/raise? (I mean an unnamed index an no label is specified) |
What do you mean with an unnamed column? Also, now |
yep maybe need to do exactly like reset index |
The name conflicts is now also a problem (if you would have a column named |
yep and I would name index |
My concern with using the name "index" is that it is not allowed as a column name in certain SQL flavors (this is a problem for other reserved keywords too). See for example http://dev.mysql.com/doc/refman/5.6/en/reserved-words.html Note - i don't know if they make the distinction between lower case and upper case versions |
@mangecoeur Good concern (and sql mostly makes no distinction between lower and upper case, with some exceptions).
So the So for postgresql this is working, and I suppose other database systems will have a similar mechanism to deal with this kind of column names? |
OK, to move forward, I am going to merge this. In any case will also have to touch it again (the naming issue) when adding multi-index support. |
SQL: add index_label keyword to to_sql
Further work on #6292. While looking at possible multi-index support, I thought of first adding this:
to_sql
(analoguous toto_csv
). Good idea?to_sql
(https://github.com/jorisvandenbossche/pandas/compare/sql-multiindex?expand=1#diff-b41f9fd042c423682f8e4c4d808dbe64R891) without using it. Is there a better approach? Should I warn that this is ignored if the user specifies this?to do:
@mangecoeur