Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: 'float' object is not subscriptable #82

Open
ahanafimhd opened this issue May 22, 2019 · 0 comments
Open

TypeError: 'float' object is not subscriptable #82

ahanafimhd opened this issue May 22, 2019 · 0 comments

Comments

@ahanafimhd
Copy link

def preprocessing(string):
string = string[2:-1] # string dimulai dari 2 sampai -1 karena data sebelumnya telah di encode
a = casefold(string) # merubah ke huruf kecil
a = tokenisasi(a) # membuat token
a = stopword_removal(a) # menghapus kata yang tidak penting
a = url_symbol_removal(a) # menghapus simbol dan link
a = ' '.join(a) # membuat array menjadi string
return a

result = []
for i in range(len(tweets)):
pre = preprocessing(tweets[i]) if preprocessing(tweets[i]) != "" else "bagus" if label[i] == 1 else "payah"
result.append({'Text' : pre,'Label' : label[i]})
df = pd.DataFrame(result) # membuat data frame dari result
df.to_csv('preprocessing result.csv', index=False, header='column_names') # mengubah dataframe ke csv


TypeError Traceback (most recent call last)
in ()
1 result = []
2 for i in range(len(tweets)):
----> 3 pre = preprocessing(tweets[i]) if preprocessing(tweets[i]) != "" else "bagus" if label[i] == 1 else "payah"
4 result.append({'Text' : pre,'Label' : label[i]})
5 df = pd.DataFrame(result) # membuat data frame dari result

in preprocessing(string)
1 def preprocessing(string):
----> 2 string = string[2:-1] # string dimulai dari 2 sampai -1 karena data sebelumnya telah di encode
3 a = casefold(string) # merubah ke huruf kecil
4 a = tokenisasi(a) # membuat token
5 a = stopword_removal(a) # menghapus kata yang tidak penting

TypeError: 'float' object is not subscriptable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant