Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

DeflateAwning
Copy link
Contributor

No description provided.

@@ -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.")
Copy link
Owner

@ThibTrip ThibTrip Dec 3, 2023

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:

Suggested change
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.")
Copy link
Owner

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 :)

Suggested change
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.")

Copy link
Owner

@ThibTrip ThibTrip left a 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.

@DeflateAwning
Copy link
Contributor Author

Updated, should be good now! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants