I have to clean a data frame with empty rows by separating the values from one column. My dataframe currently looks like this:
id_number section
0 00000 & A NaN
1 01000 B
2 01001 C
3 01003 & D NaN
4 01005 & E NaN
and i need the end result to look like this:
id_number section
0 00000 A
1 01000 B
2 01001 C
3 01003 D
4 01005 E
my code so far is
import pandas
df[['id_number','section']] = df.id_number.str.split(" & ",expand=True,)
but it returns "None" for the the cells with sections already:
id_number section
0 00000 A
1 01000 None
2 01001 None
3 01003 D
4 01005 E
Would anyone know how to fix this? Thank you!