Append tfidf to pandas dataframe

前端 未结 3 1774
旧时难觅i
旧时难觅i 2020-12-16 01:27

I have the following pandas structure:

col1 col2 col3 text
1    1    0    meaningful text
5    9    7    trees
7    8    2    text

I\'d lik

3条回答
  •  青春惊慌失措
    2020-12-16 02:08

    I would like to add some information to the accepted answer.

    Before concatenating the two DataFrames (i.e. main DataFrame and TF-IDF DataFrame), make sure that the indices between the two DataFrames are similar. For instance, you can use df.reset_index(drop=True, inplace=True) to reset the DataFrame index.

    Otherwise, your concatenated DataFrames will contain a lot of NaN rows. Having looked at the comments, this is probably what the OP experienced.

提交回复
热议问题