inputs
dsstools.inputs
clean_graph_data_attributes(graph)
Replace empty strings in data attributes with np.nan.
import_attributes_from_csv(graph, filepath, import_columns, index_label='', cleanup_functions=None)
Import attributes from CSV file with some cleanup.self.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
graph
|
DiGraph
|
Graph on which the data should be applied to. |
required |
filepath
|
str
|
Path of the CSV file. |
required |
import_columns
|
list[str]
|
Columns to be imported, can be None. |
required |
index_label
|
Column name used as index, defaults to first column. (default None) |
''
|
|
cleanup_functions
|
Functions
|
to be applied on the DataFrame. (default None) |
None
|
Returns:
Type | Description |
---|---|
DiGraph
|
nx.DiGraph: Graph with the applied data. |
import_attributes_from_dataframe(graph, df)
Import attributes from Pandas dataframe.
The index of the dataframe should be the name of the graph node. Non-existing nodes are ignored and will not get the attribute.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
graph
|
DiGraph
|
Graph on which the data should be applied to. |
required |
filepath
|
DataFrame
|
Path of the CSV file. |
required |
import_columns
|
list[str]
|
Columns to be imported, can be None. |
required |
Returns:
Type | Description |
---|---|
DiGraph
|
nx.DiGraph: Graph with the applied data. |
import_from_dsscode(slug, snapshot, token, domain='dss-graph.wiso.uni-hamburg.de', cache=True, remove_selfloops=True, contract_redirects=False, explicit_include=False)
Import Graph object from dssCode.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
slug
|
str
|
Name slug of the project (see dssCode-Interface) |
required |
snapshot
|
str
|
Snapshot hash |
required |
domain
|
str
|
The domain for the API call |
'dss-graph.wiso.uni-hamburg.de'
|
cache
|
(bool, Path, str)
|
Pass the cache directory. Defaults to temporary dir. |
True
|
remove_selfloops
|
bool
|
Remove edge selfloops. |
True
|
contract_redirects
|
bool
|
Contract redirecting nodes into one. |
False
|
explicit_include
|
bool
|
Include only explicitely marked nodes into graph |
False
|
Returns:
Type | Description |
---|---|
DiGraph
|
nx.DiGraph: Graph with the imported data. |
import_network(filepath, remove_selfloops=True)
Import network as a NetworkX directed graph and clean up circular edges.
read_from_pickle(folder='', timestamp='')
Read cached graph from directory.
Automatically selects the newest instance, except a timestamp is given.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir
|
(str, Path)
|
Path to directory to search for pickles. If empty, default to temp dir. |
required |
timestamp
|
str
|
timestamp to explicitely select for. |
''
|
Returns:
Type | Description |
---|---|
DiGraph
|
nx.DiGraph: Graph with the imported data. |