so I'm working on my CSV file, it has a blank like cell " " after every sentence as shown in the picture below.
when I print the columns type using:
print(data.dtypes)
I get that they are all objects, however I want the columns word_id, head_pred_id, sent_id and run_id to be int64.
when I convert column datatype using:
data.word_id = data.word_id.astype(int)
I get an error : invalid literal for int() with base 10:' '
So I thought the blank spaced-cells are making the problem so I replaced them in CSV file itself with NULL instead.
Now the 4 columns type are automatically set to "Float64" however when I perform something on them I get the same error : ValueError: invalid literal for int() with base 10: ''
I double checked if there's a cell that I missed but I didn't miss any the blank cells are all set to NULL in my CSV file.
Below is a snippet of code where the error appears:
def encode_inputs(sents):
"""
Given a dataframe which is already split to sentences,
encode inputs for rnn classification.
Should return a dictionary of sequences of sample of length maxlen.
"""
word_inputs = []
pred_inputs = []
pos_inputs = []
assert(all([len(set(sent.run_id.values)) == 1
for sent in sents]))
run_id_to_pred = dict([(int(sent.run_id.values[0]),
get_head_pred_word(sent))
for sent in sents]) ***ERROR HERE****
and this is the variable "sents" that's sent to the above function
def get_sents_from_df( df):
#Split a data frame by rows accroding to the sentences
return [df[df.run_id == run_id]
for run_id
in sorted(set(df.run_id.values))]
