0

I have a dataframe with three Columns "Tasks, Instructions" and "len" (character length of Instructions).

I want to groupby the "Instructions" by "Tasks" and concatenate the rows of "Instructions" until next full stop (character) and up to a max of 100 characters per row.

For Example:

d = {'Tasks': ["TaskOne","TaskOne","TaskTwo","TaskTwo"], 'Instructions': ["longTextofInstructionsforTask1", "longTextofInstructionsforTask1","longTextofInstructionsforTask2 additional text", "longTextofInstructionsforTask2 additional text"]}

df = pd.DataFrame(data=d)
CURRENT DATAFRAME

     Tasks                  Instructions                    len
0   TaskOne longTextofInstructionsforTask1                  30
1   TaskOne longTextofInstructionsforTask1                  30

2   TaskTwo longTextofInstructionsforTask2 additional text  46
3   TaskTwo longTextofInstructionsforTask2 additional text  46

DESIRED OUTCOME

     Tasks                  Instructions                                          len
0   TaskOne longTextofInstructionsforTask1 longTextofInstructionsforTask1         60
1   TaskTwo longTextofInstructionsforTask2 additional text longTextofInstructionsforTask2additional text                                                                              92

0 Answers0