Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Bug and Enhancement request of replace function. #671

Closed
toshiakiasakura opened this issue Jun 10, 2022 · 4 comments
Closed

Bug and Enhancement request of replace function. #671

toshiakiasakura opened this issue Jun 10, 2022 · 4 comments

Comments

@toshiakiasakura
Copy link

toshiakiasakura commented Jun 10, 2022

Current Behavior:

  • Open jupyter lab
  • read df with pd.read_csv
  • oepn dtale by dtale.show()
  • Select a column, and select Replacements
  • Select replacement type as Contains Char/Substring
  • Fill Search for and replace with
  • Push Replace button

However, this can not replace cells with inclusion of search for characters.

The current auto-generated code is like this.

import re

regex_pat = re.compile(r'^ *' + re.escape('Kraeff') + ' *$', flags=re.UNICODE)
df.loc[:, 'Name'] = df['Name'].replace(regex_pat, 'AAAA', regex=True)

However, regex_pat part of line, should be like this.

regex_pat = re.compile(r'^.*' + re.escape('Kraeff') + '.*$', flags=re.UNICODE)

After replacing space with dot, it works well.

Also, I want partial replacement function, which can be achieved by df["name"].str.replace("hoge", "non")
Without this type of replacement functions, we can not confotably use dtale for data cleaning purposes.

I am very fascinated with this open source package, so that I hope the suggested bug will be fixed and function will be implemented.

@toshiakiasakura toshiakiasakura changed the title Bug and Enhancement of replace function. Bug and Enhancement request of replace function. Jun 10, 2022
@aschonfeld
Copy link
Collaborator

@toshiakiasakura great suggestion! I'll work on adding these fixes/features and let you know when a new version is ready. Thanks

@aschonfeld
Copy link
Collaborator

@toshiakiasakura I did some more digging and I forgot that the partial replacement is available you just need to go to "Dataframe Functions" in the main menu and then select the column you want and the replacement you want made. Also if you don't want to create a new column select "Inplace"
image

If you want I can look into adding this function to the "Replacements" popup

@toshiakiasakura
Copy link
Author

Thank you very much!
I think if the partial replacement function is also built in the "Replacements" popup, it becomes more user friendly, and I like that way. It will be consistent, and we can easily find functions.

@aschonfeld
Copy link
Collaborator

@toshiakiasakura just released v2.6.0 with these enhancements/updates

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants