I am trying to place all of a strings values, into a data frame where the rows*columns= the length of the string. So for i have
for i in range (len(string)):
while(j<len(df)|z<len(df.columns)):
df[j][z]=string[i]
df
But df returns with all values as NAN, ive tried using double nested for loops aswell to no affect, aswell an if else statement checking if the index doesnt go over out of bounds for the string. Thank you.
CodePudding user response:
You can turn the string into an array of the appropriate size with something like
np.array(list(string)).reshape(len(df), -1)
Placing it in the DF should be simple after that, assuming it has a character dtype across all columns.