I have following challenge, where I'd like to ask for your support. Suppose you have a frame with multiple columns. Here I focus on the important column (name)
df=pd.DataFrame({"Name":["This is a long string", "This an even longer string", "This is the
longest string"]})
Name
0 This is a long string
1 This is an even longer string
2 This is the longest string
The Name Column has the characteristics that it is allowed to contain a string of length maximum 10. If the rule is violated it should split the string into substrings and expand it into additional columns, which all have the same characteristics of string length 10
Question: How can I split the column Name in a way that the outcome should look like this
Name Name1 Name2 Name3
"This is a" "long string"
"This is an" "even" "longer" "String"
I tried multiple approaches, however without success.
I'd be already happy if you could support me in splitting the Name column into substrings if a string length of 10 is reached, i.e. two columns, the first column containing the string with length lower than 10 and then the second column the remaining string, i.e.
Name Name1
"This is a" "longer string"
"This is an" "even longer string"
"This is" "the longest string"