-4

I am trying to split a string using .str.split('$_') but this is not working.

Other combinations like 'W_' or '$' work fine but not '$'. I also tried .str.replace('$') - which also does not work.

Initial string is '$WA:G_COUNTRY'

using ClearanceUnq['Clearance'].str.split('$_') results in [$WA:G_COUNTRY] no split....

whereas ClearanceUnq['Clearance'].str.split('$') results in [, WA:G_COUNTRY] as expected

Frank
  • 1
  • *does not work* . What does it say? Is there any error? Which python version are you using? – Nouman Sep 13 '19 at 03:31
  • _Other combinations like 'W\_' or '$' work fine but not '$'_ I'm confused. Does `$` work, or not? – John Gordon Sep 13 '19 at 03:35
  • Thanks for your response - for some reason the text editor body changed ('$_') to ('$'). Which then presents my question as rubbish leading to the comments. This perhaps offers some insights into the issue I have experienced. My string is dollar sign underscore eg ''$_WA:G_COUNTRY''. when I use .str.split('$_') to split the string it simply doesn't split the string result for the above is '[$_WA:G_COUNTRY]' - I have use split many time with many combinations and never had an issue. I'll guarantee this does not work. – Frank Sep 16 '19 at 01:07

1 Answers1

2

This is because it is trying to split the string when it finds a $ AND a _ right next to eachother, which does not occur in your first string.

DanielAaron
  • 101
  • 8