text_plain_output_5.png application_vnd.jupyter.stderr_output_2.png text_plain_output_4.png text_plain_output_6.png application_vnd.jupyter.stderr_output_3.png text_plain_output_7.png text_plain_output_8.png application_vnd.jupyter.stderr_output_1.png
import pandas as pd

df = pd.read_csv('../input/misoimprovedta/ta-misogyny-train (3).csv', header=None, sep='\t')
df_eval = pd.read_csv('../input/misoimprovedta/ta-misogyny-dev (2).csv', header=None, sep='\t')
df_test = pd.read_csv('../input/misoimprovedta/ta-misogyny-test (2).csv', header=None)

def create_labels(sentence):
    splits = sentence.split('\t')
    return splits[0]
def change_sentence(sentence):
    splits = sentence.split('\t')
    return splits[1]
df_eval.rename(columns={0: 'Labels', 1: 'Text'}, inplace=True)
df_eval = df_eval[['Text', 'Labels']]
df.rename(columns={0: 'Labels', 1: 'Text'}, inplace=True)
df = df[['Text', 'Labels']]
df_test.rename(columns={0: 'Text'}, inplace=True)

num_labels = len(df['Labels'].unique())
keys = list(df['Labels'].unique())
values = list(range(0, num_labels))
label_dict = dict(zip(keys, values))
df['Labels'] = df['Labels'].apply(lambda x: label_dict[x])
df_eval['Labels'] = df_eval['Labels'].apply(lambda x: label_dict[x])

df_final = df_test.copy()
reverse_label_dict = {v: u for u, v in label_dict.items()}
reverse_label_dict
df_final['Predicted_Labels'] = predictions
df_final['Predicted_Labels'] = df_final['Predicted_Labels'].apply(lambda x: reverse_label_dict[x])
df_final['pid'] = df_final.index
df_final = df_final[['pid', 'Predicted_Labels']]

df_final