If the line sf.set_data_dir is omitted, the following error is raised:
TypeError: expected str, bytes or os.PathLike object, not NoneType
This error is very cryptic and it's not clear for the user that the explicit setting of the data path is missing.
A solution would be to either display an error message like:
Error: Data directory not specified, please specify a data directory using sf.set_data_dir
OR
select the home directory of the user by default (and append simfin_data) if no data directory is specified explicitely:
from pathlib import Path
import os
home = str(Path.home())
default_directory = os.path.join(home, "simfin_data")
Full Code to Reproduce Error
import pandas as pd
# Import the main functionality from the SimFin Python API.
import simfin as sf
# Import names used for easy access to SimFin's data-columns.
from simfin.names import *
df1 = sf.load(dataset='income', variant='annual', market='us')
Description
If the line
sf.set_data_dir
is omitted, the following error is raised:TypeError: expected str, bytes or os.PathLike object, not NoneType
This error is very cryptic and it's not clear for the user that the explicit setting of the data path is missing. A solution would be to either display an error message like: Error: Data directory not specified, please specify a data directory using sf.set_data_dir OR select the home directory of the user by default (and append simfin_data) if no data directory is specified explicitely:
Full Code to Reproduce Error