Python Forum
EOL while scanning string literal - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: EOL while scanning string literal (/thread-18319.html)



EOL while scanning string literal - AdWill97 - May-13-2019

I am trying to change the name of my headers in my dataframe which include '\\PXI-PC\KWKK\PXI-PC\KWKK_sv\'.
I would like to remove this and replace it with nothing but keep getting 'SyntaxError: EOL while scanning string literal'
appreciate any help and also is there any way to just snip that part away rather than replace with nothing, can i even replace with nothing must something be entered?

df.columns = df.columns.str.replace('\\PXI-PC\KWKK\PXI-PC\KWKK_sv\' , '')
thanks in advance


RE: EOL while scanning string literal - Larz60+ - May-13-2019

Please show snippet with enough supporting code to run it.


RE: EOL while scanning string literal - AdWill97 - May-14-2019

Hi sorry didn't show enough I ended up getting around it by just renaming the columns individually

df['\\\PXI-PC\KWKK\PXI-PC\KWKK_sv\OC_HC_B_T_M__FL'] = df.rename(columns = {'\\\PXI-PC\KWKK\PXI-PC\KWKK_sv\OC_HC_B_T_M__FL':'fl_temp'}, inplace=True)
df['\\\PXI-PC\KWKK\PXI-PC\KWKK_sv\AUX_HC_A_T_M__'] = df.rename(columns = {'\\\PXI-PC\KWKK\PXI-PC\KWKK_sv\AUX_HC_A_T_M__':'amb_temp'}, inplace=True)