I don't know if I can post a question for 2 separate programming languages in the same post. If not, I will be happy to post them as separate questions. A solution in either one of the languages (R or Pyspark) would suffice.
I am trying to split a column into 2 columns using the _
delimiter only on the first instance. However, there are values that have more than one instance of the delimiter. For example:
Input Expected Output
BCT_12 [BCT] [12]
HDR_40_50 [HDR] [40_50]
500_ERP_70 [500] [ERP_70]
Currently, I am counting the number of _
and using a for loop to split all of them and concatenate the columns after the first instance. But it is quite clunky and prone to breaking.
Would love to know if there is an elegant method to do this.