text_plain_output_1.png
import pandas as pd

import re

import pandas as pd
df_fb2021 = pd.read_csv('../input/feedback-prize-2021/train.csv', dtype={'discourse_id': int})
df_fb2021['textlen'] = df_fb2021.discourse_text.str.len()
df_fb2021

import re
def join_texts(v):
    return re.sub(' +', ' ', ' '.join(v.discourse_text).replace('\n', ' ').replace('\x07', ' '))
df_fb2021_agg = df_fb2021.groupby('id').apply(lambda v: join_texts(v)).to_frame('text')
df_fb2021_agg

df_fb2021_agg.sample().text.item()

df_fb2021_agg.text.str.len().plot.hist(bins=100)