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

Changing values on a filtered table (with inplace=True) does not update the underlying DataFrame #745

Open
DiegoF90 opened this issue Mar 30, 2023 · 1 comment

Comments

@DiegoF90
Copy link

Pretty much what the issue tittle says. For example use the below (e.g. in Jupyter Notebook):

import pandas as pd
import dtale

df = pd.DataFrame({'a': ['yes', 'no', 'no', 'maybe'], 'b': ['foo', 'bar', 'spam', 'eggs']})
dtale.show(
    df,
    inplace=True
)

Then filter column 'a' by those having value 'no'. Than delete the entries of column 'b'. A pandas warning on setting a value on a copy will appear, and as suggested when printing

df

Column 'b' will still show contents.

@aschonfeld
Copy link
Collaborator

@DiegoF90 so inplace=True might be a little misleading. On initial load of a dataframe to D-Tale a call to reset_index occurs (this is to ensure the dataframe is in a normalized format with a standard "natural" index of 0...n). When you call dtale.show with inplace=True it will make that call to reset_index an inplace operation to lower memory usage. Unfortunately, this is where that flag's usage ends.

What you want to do in order to get your updated dataframe would be:

import pandas as pd
import dtale

df = pd.DataFrame({'a': ['yes', 'no', 'no', 'maybe'], 'b': ['foo', 'bar', 'spam', 'eggs']})
d = dtale.show(
    df,
    inplace=True
)

# perform edits using the app

d.data # this retrieves the current state of your dataframe (with regard to edits, not filtering)

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

2 participants