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

Editing cells with specific predefined values #659

Closed
ricnov opened this issue Apr 13, 2022 · 4 comments
Closed

Editing cells with specific predefined values #659

ricnov opened this issue Apr 13, 2022 · 4 comments

Comments

@ricnov
Copy link

ricnov commented Apr 13, 2022

Hi, is it possible to edit cells with predefined specific values (not data type)? For example in a column with string data type it allows only "yes", "no" or "maybe". Thanks

@ricnov ricnov changed the title Editing cells with specific values Editing cells with specific predefined values Apr 25, 2022
@aschonfeld
Copy link
Collaborator

@ricnov still working on supporting your full functionality, but just released v2.10.0 with an update where if your column is a category. It will allow you to choose from the different categories when editing. So for your example you could create a categorical column with values (yes, no, maybe).

I'll keep working on this feature so that you're not limited to categorical columns. Will keep you posted

@aschonfeld
Copy link
Collaborator

@ricnov I'm about to merge an update to support this functionality. Here is how it would work:

import pandas as pd
import dtale

# Option 1 -> using 'column_edit_options' parameter
dtale.show(pd.DataFrame(dict(foo=['yes'])), column_edit_options=dict(foo=['yes', 'no', 'maybe']))

# Option 2 -> updating settings on instance
d = dtale.show(pd.DataFrame(dict(foo=['yes'])))
d.update_settings(column_edit_options=dict(foo=['yes',' no', 'maybe']))

# Option 3 -> updating settings using instance ID
from dtale.views import _update_settings

d = dtale.show(pd.DataFrame(dict(foo=['yes'])))
_update_settings(d._data_id, dict(column_edit_options=dict(foo=['yes', 'no', 'maybe'])))

Let me know if you have any issues with this or tweaks you'd like made. If I don't hear anything I'll move forward with this change and let you know when a new version is out there

@aschonfeld
Copy link
Collaborator

@ricnov just released v2.11.0 with this feature. Please let me know if you have any issues. I've also added another option for setting options for column editing. Following this documentation you can add the following to the [show] section for it to be applied to every dataframe you load into D-Tale without specifying parameters in your code:

column_edit_options = {"foo": ["yes", "no", "maybe"]}

Lastly, if you haven't already please toss your ⭐ on the repo. Thanks 🙏

@DiegoF90
Copy link

I can see that "nan" is always a value, regardless of what options are passed. Is it possible for it to use only the options given?

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