hadi javanmard
hadi javanmard

Reputation: 143

implement a text classifier with python

i try to implement a Persian text classifier with python, i use excel to read my data and make my data set. i would be thankful if you have any suggestion about better implementing.

i tried this code to access to body of messages which have my conditions and store them. i took screenshot of my excel file to help more. for example i want to store body of messages which its col "foolish" (i mean F column) have value of 1(true). https://ibb.co/DzS1RpY "screenshot"

import pandas as pd

file='1.xlsx'

sorted=pd.read_excel(file,index_col='foolish')

var=sorted[['body']][sorted['foolish']=='1']

print(var.head())

expected result is body of rows 2,4,6,8.

Upvotes: 0

Views: 137

Answers (1)

anky
anky

Reputation: 75100

try assigning like this:

df_data=df["body"][df["foolish"]==1.0]

dont use - which is a python operator instead use _ (underscore)

Also note that this will return a series.

For a dataframe , use:

df_data = pd.DataFrame(df['body'][df["foolish"]==1.0])

Upvotes: 1

Related Questions