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

wr.neptune.flatten_nested_df recursion fails after 1 round #3019

Open
oniht opened this issue Nov 14, 2024 · 0 comments
Open

wr.neptune.flatten_nested_df recursion fails after 1 round #3019

oniht opened this issue Nov 14, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@oniht
Copy link

oniht commented Nov 14, 2024

Describe the bug

This function fails when recursion is over level deep. This is caused by df = df.reset_index() on line 629 in _neptune.py.

The reason is that columns index and level_0 are added in the first 2 calls of flatten_nested_df and in the 3rd call it gives this error ValueError: cannot insert level_0, already exists.

How to Reproduce

data = {'0': [[{'id': 'AA1-2024-11-21-FOO-BAR', 'label': 'flight', 'properties': ['ACREG', 'ACTYPE']}]]}
df = pd.DataFrame.from_dict(data)
wr.neptune.flatten_nested_df(df)

Expected behavior

Use df = df.reset_index(drop=True) to not insert index into dataframe columns. Expected result:

0_id 0_label 0_properties
0 AA1-2024-11-21-FOO-BAR flight ACREG
0 AA1-2024-11-21-FOO-BAR flight ACTYPE

Your project

No response

Screenshots

No response

OS

Mac

Python version

3.11

AWS SDK for pandas version

3.5.2

Additional context

No response

@oniht oniht added the bug Something isn't working label Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant