0

I am trying to do text preprocessing but I found out that one single data in my text column contains float.

i=0
while True:
    for each in list_df['text']:
        print(type(list_df['text'][i]))
        i+=1

enter image description here

How can I change this into str?

1
  • 1
    df['text'].astype(str) to cast the entire column to strings. you can check by using apply df['text'].astype(str).apply(type) Commented May 9, 2021 at 22:19

1 Answer 1

1

Assuming col_x is your column name, try:

df['col_x'] = df['col_x'].astype(str)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.

Ask question

Explore related questions

See similar questions with these tags.