简体   繁体   中英

Replacing multiple special characters

I want to get rid of multiple special characters that might show up in a specific column and replace it with a space but I keep getting this error when I try to write my file to an excel document.

Exception: Invalid Excel character '[]:*?/\' in sheetname 'AL DINTE LASA/JACKY'S'

I have already tried the below but it is not working but I dont know why that should get rid of multiple special characters and then replace it with an underscore.

 df['Name'].replace(["/''//'-[]:*?/\\/#",'_'],regex=True)

I dont know what else to try I cant seem to get around this error, am I just not using df.replace correctly?

The problem is not in the spreadsheet data itself - it is in the name of the spreadsheet. Specifically, the slash is not allowed in the sheetname. You can change the name to "AL DINTE LASA-JACKY'S" and it should work fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM