https://kedro.org/ logo
#questions
Title
# questions
t

Toni

09/16/2022, 9:24 AM
Hi team! How can I save an
np.array
with the
catalog
? Is there a way to save this
np.array
as CSV "easily"? I cannot use the
pandas.CSVDataSet
because it is not a dataframe. I think that this can be done with trascoding datasets, but I do not know if there is a
dataset
for
np.arrays
in kedro.
m

Merel

09/16/2022, 9:37 AM
We don’t have any
numpy
datasets, but perhaps you can convert your array to something that can be saved in the available datasets? You can find the full list of options here: https://kedro.readthedocs.io/en/stable/kedro.extras.datasets.html#module-kedro.extras.datasets
đź‘Ť 1
a

Antony Milne

09/16/2022, 10:35 AM
Given that a
pandas.DataFrame
wraps
np.array
, probably the easiest approach is indeed to just generate a
pd.DataFrame
from the array and then use
pandas.CSVDataSet
. There’d be a small performance hit associated with doing this compared to doing
np.array.savetxt
directly but shouldn’t matter unless you’re dealing with really big arrays.
K 1