deepchem
deepchem copied to clipboard
To_csv method is not working
🐛 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
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 I understood thatNumpyDataset.to_csv()
is working, but according to the example you gave me, NumpyDataset also doesn't work!
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")