I created a straightforward Python script :
import pandas # as pd unnecessary
class dataset:
"""
The dataset class aims to take a dataset, define a target and
draw all descriptive statistics into a Python widget.
INPUT : df, a Pandas dataframe
target, a string denoting a column
"""
def __init__(self,df,target):
self.df = df
self.target = target
# Checking errors
if ~isinstance(df, pandas.core.frame.DataFrame):
raise TypeError("df is not a Pandas dataframe.")
if ~isinstance(target,str):
raise TypeError("target is not a string variable.")
if target not in df.columns:
raise ValueError("The target is not available in the dataframe.")
Yet when I want to import it in a Jupiter notebook this way (the two scripts are in the same folder, the one above being named datavizToolbox.py
) :
from datavizToolbox import dataset
It yields that it is unable to import :
ImportError: cannot import name 'dataset' from 'datavizToolbox' (* My path *)
Is there something I am missing ?