deepgraph.DeepGraph.return_cs_graph
- DeepGraph.return_cs_graph(relations=False, dropna=True)[source]
Return
scipy.sparse.coo_matrixrepresentation(s).Create a compressed sparse graph representation for each type of relation given by
relations.relationscan either be False, True, or a (list of) column name(s) ofe. Ifrelationsis False (default), return a single csgraph entailing all edges ine.index, each with a weight of 1 (in that case,dropnais discarded). Ifrelationsis True, create one csgraph for each column ofe, where the weights are given by the columns’ values. If only a subset of columns is to be mapped to csgraphs,relationshas to be a (list of) column name(s) ofe.The argument
dropnaindicates whether to discard edges with NA values or not. Ifdropnais True or False, it applies to all types of relations given byrelations. However,dropnacan also be array_like with the same shape asrelations(or with the same shape ase.columns, ifrelationsis True).- Parameters:
relations (bool, str or array_like, optional (default=False)) – The types of relations to be mapped to scipy csgraphs. Can be False, True, or a (list of) column name(s) of
e.dropna (bool or array_like, optional (default=True)) – Whether to drop edges with NA values. If True or False, applies to all relations given by
relations. Otherwise, must be the same shape asrelations. Ifrelationsis False,dropnais discarded.
- Returns:
csgraph – A dictionary, where keys are column names of
e, and values are the correspondingscipy.sparse.coo_matrixinstance(s). If only one csgraph is created, return it directly.- Return type:
scipy.sparse.coo_matrix or dict
See also