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

Missing check if the renamed column is listed under self._convert_dates() before referring to it leads to a KeyError. #60536

Open
seppliv opened this issue Dec 10, 2024 · 1 comment · May be fixed by #60539
Labels
Bug IO Stata read_stata, to_stata

Comments

@seppliv
Copy link

seppliv commented Dec 10, 2024

When checking and fixing column names for writing a Stata file, there is an added check to see whether the renamed column also needs to be renamed under the _convert_dates class attribute (a dict). However, there is a missing condition to see if the renamed column name is actually listed under the _convert_dates dict, and so it raises KeyError every time such variable name is not found in the dict keys. A simple condition such as that below would probably do the trick:
if c != o and o in self._convert_dates:

if c != o:

@Uvi-12 Uvi-12 linked a pull request Dec 11, 2024 that will close this issue
@rhshadrach
Copy link
Member

Thanks for the report. Can you provide a reproducible example demonstrating the issue.

@rhshadrach rhshadrach added Bug IO Stata read_stata, to_stata labels Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO Stata read_stata, to_stata
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants