0

I did tfidf with manual syntax and I got the results of the tf idf vector in the form of a data series. the data is as follows:

print(type(dataset["TFIDFVec"]))
print(dataset["TFIDFVec"])

<class pandas.core.series.Series>
0       [0.0, 0.6307448112902039, 0.0, 0.0, 0.0, 0.0, ...
1       [0.0, 0.0, 1.3985703304477997, 0.0, 0.0, 0.0, ...

I want to convert it to an array. I use to_numpy() code but it output list in array. what I tried is the following:

tfidffixarr = dataset["TFIDFVec"].to_numpy()
tfidffixarr

array([list([0.0, 0.6307448112902039, 0.0, 0.0,...,0.0]),
      list([0.0, 0.0, 0.0, 0.0,...,0.0])],

I want it to be jut like this:

[[0 0.6307448112902039 0,..., 0 0 0]
 [0 0 0 ,..., 0 0 0]
 [0 0 0 ,..., 0 0 0]]

Does anyone know how to fix it?

2

1 Answer 1

1

To Python list:

list(dataset["TFIDFVec"])
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.