deepchem icon indicating copy to clipboard operation
deepchem copied to clipboard

To_csv method is not working

Open bibs2091 opened this issue 1 year ago • 3 comments

🐛 Bug

I was trying to save my dataset to a CSV file but deepchem is telling me that the the method to_csv doesn't exist for numpydataset or diskdataset.

To Reproduce

If you run the example in the official docs:

import numpy as np
X = np.random.rand(10, 10)
dataset = dc.data.DiskDataset.from_numpy(X)
dataset.to_csv('out.csv')  

You will have an error "AttributeError: 'DiskDataset' object has no attribute 'to_csv'"

Expected behavior

Environment

  • OS: Macos
  • Python version: 3.9
  • DeepChem version: 2.6.1

bibs2091 avatar Sep 08 '22 13:09 bibs2091

dataset has to be NumpyDataset.

import numpy as np
X = np.random.rand(10, 10)
dataset = dc.data.NumpyDataset(X=X)
dataset.to_csv('out.csv')

If you want to use to_csv in DiskDataset, you should have deepchem nightly version installed - DiskDataset.to_csv was added recently.

arunppsg avatar Sep 08 '22 13:09 arunppsg

@arunppsg I understood thatNumpyDataset.to_csv()is working, but according to the example you gave me, NumpyDataset also doesn't work!

bibs2091 avatar Sep 08 '22 14:09 bibs2091

In that case using NumpyDataset.to_dataframe().to_csv would help:

import numpy as np
X = np.random.rand(10, 10)
dataset = dc.data.NumpyDataset(X=X)
dataset.to_dataframe().to_csv("out.csv")

osbm avatar Oct 01 '22 10:10 osbm