![]() Replacing the column in question with a column where the emdash is replaced with a +. So i used it as such: df = df.str.replace(u'\u2014', '+') str.replace doesnt work for multicolumn dataframes. in order for str.replace to work you need to use it on a single column only. I hope this helps future visitors, at least i will be able to look this up next time before wasting hours debugging. Which corresponds to the utf-8 hex representation 0圎2 0x80 0x94 Remember to remove the spaces afterwards if you use this method. wordword) will autocorrect to an em dash. With Windows, there are three ways to type an em dash: In Microsoft Word, two hyphens between two words without spaces (e.g. so for python 3 use "\u2014"įyi lastly the utf-8 hex representation works as well. On a Mac, you type an em dash by holding down the shift and option keys while pressing hyphen (-). In python2.7 you need to start the string with 'u' since only from version 3 onwards python interprets every string as unicode by default. ![]() in my case it was returned as 8212 which is in python u"\u2014" Solution thanks to I am adding a few more points to solve this problem, since it was driving me bonkers.įirst check the unicode character you are dealing with using print(ord(u'-'))įind the python source code for it. UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 9: ordinal not in range(128)Īm stuck on this. I am trying to simply replace the em dash '-' with something else. Now press and release the compose key, then type - to get the em-dash. Under Compose key position (drop-down), choose a key to use for composing I chose the Right Win (right Windows key). # my_str.replace(b'\xe2\x80\x94'.decode('utf-8'), '-') Under Typing tab, select Layout Settings link (at the bottom of the dialog box). This is what I have got # -*- coding: utf-8 -*. I have tried a bunch of different suggestions. Select it and click OK .I am trying to remove the 'em dash' from a pandas DataFrame. Scroll down until you find the en dash (U+2013) character. Use Insert → Special Characters to open the Special Characters dialog.Use Tools → Macros → Record Macro to start recording a macro.Ī small window is displayed so you know that Apache OpenOffice is recording.Step 1: Record macros for inserting en and em dashes. You can also record macros for inserting dashes and assign those macros to key combinations. Record Macros and Assign Them to Shortcut Keys For an em dash, the combination is ⇧ Shift + ⌥ Opt + Hyphen . Hold down the Option ( Alt) key and type a hyphen for an en dash. To end the input sequence, press either the Return key or release the Ctrl/Shift keys. On Linux distributions based on the Gnome/GTK+ desktop environment, you can also input Unicode characters by pressing Ctrl + ⇧ Shift + U , followed by the hexadecimal value of the Unicode character (2013 for an en dash, 2014 for an em dash). the Windows key), and should be user-configurable. It is usually ⇧ Shift + AltGr , but may be another key (e.g. The key that operates as a Compose key varies with the Linux distribution. The dash appears when you release the Alt key. Hold down one of the Alt keys and type on the numeric keypad: 0150 for an en dash or 0151 for an em dash. The shortcuts vary depending on your operating system. ![]() Many people like to use keyboard shortcuts, especially when editing existing material that includes incorrectly-done dashes. Select the U+2013 or U+2014 character, respectively. In the following table, the A and B represent text consisting of letters A to z or digits 0 to 9.Ī - B (A, space, minus, minus, space, B)Īnother means of inserting en or em dashes is through the Insert → Special Characters menu. This method uses the Replace dashes option under Tools → AutoCorrect → Options to replace one or two hyphens, under certain conditions, with the corresponding dash.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |