diff --git a/visidata/loaders/npy.py b/visidata/loaders/npy.py index 8003b2f7d..d9c9e46f8 100644 --- a/visidata/loaders/npy.py +++ b/visidata/loaders/npy.py @@ -14,7 +14,7 @@ def open_npz(vd, p): class NpySheet(Sheet): def iterload(self): - import numpy + vd.importExternal('numpy') if not hasattr(self, 'npy'): self.npy = numpy.load(str(self.source), encoding='bytes', **self.options.getall('npy_')) self.reloadCols() @@ -47,12 +47,12 @@ class NpzSheet(vd.ZipSheet): ] def iterload(self): - import numpy + vd.importExternal('numpy') self.npz = numpy.load(str(self.source), encoding='bytes', **self.options.getall('npy_')) yield from Progress(self.npz.items()) def openRow(self, row): - import numpy + vd.importExternal('numpy') tablename, tbl = row if isinstance(tbl, numpy.ndarray): return NpySheet(tablename, npy=tbl) @@ -62,7 +62,7 @@ def openRow(self, row): @VisiData.api def save_npy(vd, p, sheet): - import numpy as np + np = vd.importExternal('numpy') dtype = [] diff --git a/visidata/loaders/pandas_freqtbl.py b/visidata/loaders/pandas_freqtbl.py index c4af1e9ca..be37f5976 100644 --- a/visidata/loaders/pandas_freqtbl.py +++ b/visidata/loaders/pandas_freqtbl.py @@ -11,8 +11,8 @@ class DataFrameRowSliceAdapter: by visidata's selectRow implementation. """ def __init__(self, df, mask): - import pandas as pd - import numpy as np + pd = vd.importExternal('pandas') + np = vd.importExternal('numpy') if not isinstance(df, pd.DataFrame): vd.fail('%s is not a dataframe' % type(df).__name__) if not isinstance(mask, pd.Series):