-1

So my current column looks like this

Name New Name
A A
B,A B
c A
D,G C

So, some field have multiple value and some don't, how do i separate them into a single value.

Anurag Dabas
  • 23,866
  • 9
  • 21
  • 41

2 Answers2

0

IIUC:

try via upper(),split() and explode() method:

df['New Name']=df['Name'].str.upper().str.split(',').explode(ignore_index=True)[0:len(df)]

output of df:

   Name     New Name
0   A       A
1   B,A     B
2   c       A
3   D,G     C
Anurag Dabas
  • 23,866
  • 9
  • 21
  • 41
-1

I’m not super familiar with tables but I’m sure you could still use string.split(“,”)

Tony Dean
  • 132
  • 7
  • I tried that, it returns None for fields which don't have multiple values –  Jun 18 '21 at 04:34