-1

I have a dataset in pkl file, and I write the following code to unpkl the file and read the data

import pickle
f=open("data_cdg.pkl","rb")
a = pickle.load(f)
f.close()
print(a)

but I got in the output 67 sparse matrix of type '<class 'numpy.int64'>' so how I can read the content of the dataset in python?

1 Answer 1

0

There is a read_pickle function as part of pandas 0.22+

import pandas as pd

object = pd.read_pickle("data_cdg.pkl")
1
  • I got the same result , i need to read the content of data set when i wrote your code i got this output so how I can read the content of data?67x67 sparse matrix of type '<class 'numpy.int64'>' with 132 stored elements in Compressed Sparse Row format>, 39773: <172x172 sparse matrix of type '<class 'numpy.int64'>' with 342 stored elements in Compressed Sparse Row format>, 1396: <17x17 sparse matrix of type '<class 'numpy.int64'>' with 32 stored elements in Compressed Sparse Row format>, 623: <125x125 sparse matrix of type '<class 'numpy.int64'>' Commented Feb 5, 2022 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.