-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add more helpful error message for UnnamedIndexLevelsException #84
base: master
Are you sure you want to change the base?
Conversation
pangres/engine.py
Outdated
@@ -127,7 +127,7 @@ def __init__(self, | |||
# all index levels have names | |||
index_names = list(df.index.names) | |||
if any(ix_name is None for ix_name in index_names): | |||
raise UnnamedIndexLevelsException("All index levels must be named!") | |||
raise UnnamedIndexLevelsException("All index levels must be named! Ensure you used `df = df.set_index(['col1', 'col2', ...])` before.") |
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.
Hey, that looks good but the line is too long (must be <= 120 characters), so I suggest doing so:
raise UnnamedIndexLevelsException("All index levels must be named! Ensure you used `df = df.set_index(['col1', 'col2', ...])` before.") | |
raise UnnamedIndexLevelsException("All index levels must be named! " | |
"Ensure you used `df = df.set_index(['col1', 'col2', ...])` before.") |
pangres/utils.py
Outdated
@@ -88,7 +88,7 @@ def fix_psycopg2_bad_cols(df: pd.DataFrame, replacements: dict = {'%': '', '(': | |||
# verify all index levels are named | |||
index_names = list(df.index.names) | |||
if any([ix_name is None for ix_name in index_names]): | |||
raise UnnamedIndexLevelsException("All index levels must be named!") | |||
raise UnnamedIndexLevelsException("All index levels must be named! Ensure you used `df = df.set_index(['col1', 'col2', ...])` before.") |
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.
Same comment as for the other file :)
raise UnnamedIndexLevelsException("All index levels must be named! Ensure you used `df = df.set_index(['col1', 'col2', ...])` before.") | |
raise UnnamedIndexLevelsException("All index levels must be named! " | |
"Ensure you used `df = df.set_index(['col1', 'col2', ...])` before.") |
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.
Please handle the problems I mentioned with lines being too long, then we will be good to go.
Updated, should be good now! Thanks! |
No description provided.