Python Forum

Full Version: EOL while scanning string literal
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
Please show snippet with enough supporting code to run it.
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)