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

RecursionError when multiple columns have same names #61

Open
meain opened this issue May 25, 2021 · 3 comments
Open

RecursionError when multiple columns have same names #61

meain opened this issue May 25, 2021 · 3 comments
Assignees

Comments

@meain
Copy link

meain commented May 25, 2021

If I have multiple columns with same names(usually after I trim it to just 8 chars), I get a RecursionError: maximum recursion depth exceeded when running the following code.

import pandas as pd
import xport
import xport.v56


df = pd.read_csv("temp.csv")
ds = xport.Dataset(df, name="DATA", label="Wonderful data")
ds = ds.rename(columns={k: k.upper()[:8] for k in ds})  # <- can happen here
library = xport.Library({"DATA": ds})
with open("example.xpt", "wb") as f:
    xport.v56.dump(library, f)  # <- or here

We will get recursion error on ds.rename line, but even if we were to use something like ds.columns = [c[:8] for c in ds.colums] we get a similar error in xport.v56.dump line. The csv file that I am using is relatively simple.

BIRTHDAY_DTC,BIRTHDAY_MONTH
12/10/1999,SEPT

pip freeze

pandas is not the latest but I had to pin it to that because otherwise the sas viewer was not showing labels, but I was also having this issue with pandas==1.2.4.

click==8.0.1
importlib-metadata==4.0.1
numpy==1.20.3
pandas==1.0.3
python-dateutil==2.8.1
pytz==2021.1
PyYAML==5.4.1
six==1.16.0
typing-extensions==3.10.0.0
xport==3.2.1
zipp==3.4.1

And here is the full logs.

@gaineleanor
Copy link

gaineleanor commented Oct 29, 2021

[: 8] 

variables are not unique after slicing
image

@meain
Copy link
Author

meain commented Oct 29, 2021

Yup, I'm aware of that. Just thought that it should probably at least give a more descriptive error than the current one.

@selik
Copy link
Owner

selik commented Nov 1, 2021

Thanks for reporting this, @meain . RecursionError: maximum recursion depth exceeded in __instancecheck__ confuses me. The other recursion bug was caused by trying to log a helpful message. This looks different.

I agree we could have a better error message. Checking for uniqueness and raising a specific error for duplicates would be much better.

@selik selik self-assigned this Jan 1, 2022
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

No branches or pull requests

3 participants