CSVDatasetο
- class dgl.data.CSVDataset(data_path, force_reload=False, verbose=True, ndata_parser=None, edata_parser=None, gdata_parser=None, transform=None)[source]ο
Bases:
DGLDataset
Dataset class that loads and parses graph data from CSV files.
This class requires the following additional packages:
pyyaml >= 5.4.1
pandas >= 1.1.5
pydantic >= 1.9.0
The parsed graph and feature data will be cached for faster reloading. If the source CSV files are modified, please specify
force_reload=True
to re-parse from them.- Parameters:
data_path (str) β Directory which contains βmeta.yamlβ and CSV files
force_reload (bool, optional) β Whether to reload the dataset. Default: False
verbose (bool, optional) β Whether to print out progress information. Default: True.
ndata_parser (dict[str, callable] or callable, optional) β Callable object which takes in the
pandas.DataFrame
object created from CSV file, parses node data and returns a dictionary of parsed data. If given a dictionary, the key is node type and the value is a callable object which is used to parse data of corresponding node type. If given a single callable object, such object is used to parse data of all node type data. Default: None. If None, a default data parser is applied which load data directly and tries to convert list into array.edata_parser (dict[(str, str, str), callable], or callable, optional) β Callable object which takes in the
pandas.DataFrame
object created from CSV file, parses edge data and returns a dictionary of parsed data. If given a dictionary, the key is edge type and the value is a callable object which is used to parse data of corresponding edge type. If given a single callable object, such object is used to parse data of all edge type data. Default: None. If None, a default data parser is applied which load data directly and tries to convert list into array.gdata_parser (callable, optional) β Callable object which takes in the
pandas.DataFrame
object created from CSV file, parses graph data and returns a dictionary of parsed data. Default: None. If None, a default data parser is applied which load data directly and tries to convert list into array.transform (callable, optional) β A transform that takes in a
DGLGraph
object and returns a transformed version. TheDGLGraph
object will be transformed before every access.
- graphsο
Graphs of the dataset
- Type:
Examples
Please refer to 4.6 Loading data from CSV files.