Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I am trying to do text preprocessing but I found out that one single data in my text column contains float.
text
float
i=0 while True: for each in list_df['text']: print(type(list_df['text'][i])) i+=1
How can I change this into str?
df['text'].astype(str)
apply
df['text'].astype(str).apply(type)
Assuming col_x is your column name, try:
col_x
df['col_x'] = df['col_x'].astype(str)
Add a comment
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
df['text'].astype(str)to cast the entire column to strings. you can check by usingapplydf['text'].astype(str).apply(type)