utils4text.py
def build_convs(df):
    """
    Use parallel computing. Consider only one post at each time.
    Reconstruct the dataframe to a more conversation-like dataframe.

    Arg:
        df: A given dataframe scraped from a certain subreddit.
    Return:
        df_convs: A more conversation-like dataframe with the columns such as 
        conversation ID, subreddit, post title, author, dialog turn, and text.
    """
    # initialize conversation dataframe
    df_convs = pd.DataFrame(columns = ['subreddit', 'post title', 'author', 'dialog turn', 'text'])
    
    # consider each post
    df_link_id = df.reset_index().drop('index', axis = 1)
    row_list = []
    convs_turn = 0

    # add post from df_link_id
    post_row = df_link_id.loc[0, :]
    convs_turn += 1
    row_list.append({'subreddit': post_row['subreddit'], 'post title': post_row['title'], 
                     'author': post_row['post_author'], 'dialog turn': convs_turn, 'text': post_row['post_content']})

    # iterate over each comment from df_link_id
    for i, row in df_link_id.iterrows():
        convs_turn += 1
        row_list.append({'subreddit': row['subreddit'], 'post title': row['title'],
                         'author': row['comment_author'], 'dialog turn': convs_turn, 'text': row['comment_content']})

    df_convs = df_convs.append(pd.DataFrame(row_list))
    
    # change data types
    df_convs['dialog turn'] = df_convs['dialog turn'].astype('int32')

    return df_convs

    Use parallel computing. Consider only one post at each time.
    Reconstruct the dataframe to a more conversation-like dataframe.

    Arg:
        df: A given dataframe scraped from a certain subreddit.
    Return:
        df_convs: A more conversation-like dataframe with the columns such as 
        conversation ID, subreddit, post title, author, dialog turn, and text.
    
Use parallel computing. Consider only one post at each time.
Reconstruct the dataframe to a more conversation-like dataframe.

A given dataframe scraped from a certain subreddit.
Return:
df_convs: A more conversation-like dataframe with the columns such as
conversation ID, subreddit, post title, author, dialog turn, and text.
Use parallel computing . Consider only one post at each time . Reconstruct the dataframe to a more conversation - like dataframe . A given dataframe scraped from a certain subreddit . Return : df_convs : A more conversation - like dataframe with the columns such as conversation ID subreddit post title author dialog turn and text .
def build_convs(df):
    df_convs = pd.DataFrame(columns = ['subreddit', 'post title', 'author', 'dialog turn', 'text'])
    df_link_id = df.reset_index().drop('index', axis = 1)
    row_list = []
    convs_turn = 0
    post_row = df_link_id.loc[0, :]
    convs_turn += 1
    row_list.append({'subreddit': post_row['subreddit'], 'post title': post_row['title'], 
                     'author': post_row['post_author'], 'dialog turn': convs_turn, 'text': post_row['post_content']})
    for i, row in df_link_id.iterrows():
        convs_turn += 1
        row_list.append({'subreddit': row['subreddit'], 'post title': row['title'],
                         'author': row['comment_author'], 'dialog turn': convs_turn, 'text': row['comment_content']})
    df_convs = df_convs.append(pd.DataFrame(row_list))
    df_convs['dialog turn'] = df_convs['dialog turn'].astype('int32')
    return df_convs
def build_convs ( df ) : df_convs = pd . DataFrame ( columns = [ 'subreddit' , 'post title' , 'author' , 'dialog turn' , 'text' ] ) df_link_id = df . reset_index ( ) . drop ( 'index' , axis = 1 ) row_list = [ ] convs_turn = 0 post_row = df_link_id . loc [ 0 , : ] convs_turn += 1 row_list . append ( { 'subreddit' : post_row [ 'subreddit' ] , 'post title' : post_row [ 'title' ] , 'author' : post_row [ 'post_author' ] , 'dialog turn' : convs_turn , 'text' : post_row [ 'post_content' ] } ) for i , row in df_link_id . iterrows ( ) : convs_turn += 1 row_list . append ( { 'subreddit' : row [ 'subreddit' ] , 'post title' : row [ 'title' ] , 'author' : row [ 'comment_author' ] , 'dialog turn' : convs_turn , 'text' : row [ 'comment_content' ] } ) df_convs = df_convs . append ( pd . DataFrame ( row_list ) ) df_convs [ 'dialog turn' ] = df_convs [ 'dialog turn' ] . astype ( 'int32' ) return df_convs
Use parallel computing.
Use parallel computing .
"""
    Use parallel computing. Consider only one post at each time.
    Reconstruct the dataframe to a more conversation-like dataframe.

    Arg:
        df: A given dataframe scraped from a certain subreddit.
    Return:
        df_convs: A more conversation-like dataframe with the columns such as 
        conversation ID, subreddit, post title, author, dialog turn, and text.
    """ # initialize conversation dataframe # consider each post # add post from df_link_id # iterate over each comment from df_link_id # change data types
df