Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+9 votes

I'm getting the error that there are only float in that column

asked in CSC320 by (1 point)

4 Answers

+2 votes
 
Best answer

Whenever data is missing/blank in a data frame, it fills in as the special value NaN, which is a float value.

Probably in this case it would make sense to use fillna to fill in "No Description" or even the empty string "" for each of those cells.

See example here: https://www.geeksforgeeks.org/python-pandas-dataframe-fillna-to-replace-null-values-in-dataframe/

answered by (4.7k points)
selected by
+4 votes

You could try using this line of code to read the file:

df = pd.read_csv(r'AprTweets01.csv', lineterminator='\n',

             usecols=['Full_Text', 'User_Description'], dtype=str)
answered by (1 point)
+1

I think this is also a good approach, to force the columns to be of type string.

+2 votes

I also had that problem

answered by (1 point)
+1

I tried cast it like this str(file["User_Description"][i].
It works, but I'm so confused why would it treat a bunch of descriptions as float

+2 votes

I also encountered this problem in the first place. So I decided to do something that is not related to the User_Description data

answered by (1 point)
...