Python Forum
EOL while scanning string literal
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
EOL while scanning string literal
#1
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
Reply
#2
Please show snippet with enough supporting code to run it.
Reply
#3
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)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Invoice scanning image/pdf into text animeshsarraf 1 2,072 May-24-2019, 12:12 PM
Last Post: johnb546

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020