I have a data frame like this -
a~~b~~c~~d
e~~f~~g~~h
i~~j~~k~~l
m~~n
I want to explode the rows into columns at "~~" with first row split as the column names. Data is large and there are some rows where length of string is not same i.e there may be only two "~~" in a row. In that case I want NaN on the columns. I have tried -
df[colname].str.split("~~", 1, expand = True)
But I am getting error -
AttributeError: 'DataFrame' object has no attribute 'str'
Expected output -
a b c d
e f g h
i j k l
m n NaN NaN