text_plain_output_1.png
import numpy as np # linear algebra

import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import pandas as pd
data = pd.read_csv('../input/twitter-train/train.txt', delimiter='\n', header=None)

data_array = data.to_numpy()
x_array = np.reshape(data_array, (-1, 3))
column = ['Tweet', 'Target', 'Sentiment']
data = pd.DataFrame(data=x_array, columns=column)
data

my_dataset = data
my_dataset = my_dataset.drop(['Target', 'Sentiment'], axis=1)
my_target = data.drop(['Tweet', 'Sentiment'], axis=1)
for i in my_dataset.index:
    x = my_dataset['Tweet'][i].find('$T$')
s = my_dataset['Tweet'][1].replace('$T$', my_target['Target'][0])
j = 0
my_targetless_tweet = []
for i in range(6248):
    my_targetless_tweet.insert(i, my_dataset['Tweet'][i].replace('$T$', my_target['Target'][j]))
    j = j + 1

my_targetless_tweet = pd.DataFrame(my_targetless_tweet)
my_targetless_tweet
targetless_tweet = my_targetless_tweet.to_numpy()
new_array = np.reshape(targetless_tweet, (-1, 1))
print(new_array)
column = ['Tweet (no target)']
no_target_data = pd.DataFrame(data=new_array, columns=column)
no_target_data