pici
Pici
TODO
Add documentation.
Examples:
from communities import OEMCommunityFactory, OSMCommunityFactory, PPCommunityFactory
p = Pici(
communities={
'OpenEnergyMonitor': OEMCommunityFactory,
'OpenStreetMap': OSMCommunityFactory,
'PreciousPlastic': PPCommunityFactory,
},
start='2017-01-01',
end='2017-12-01',
cache_nrows=5000
)
__init__(communities=None, labels=[], cache_dir='cache', cache_nrows=None, start=None, end=None)
Loads communities.
Communities can be loaded from cache or scraped. Loaded data can be restricted either
by number of rows loaded from cache (cache_nrows
), or by setting start
and
end
dates (filter on publication dates of posts).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
communities |
dict of str
|
pici.CommunityFactory): Dictionary of communities.
Communities are provided as |
None
|
cache_dir |
str
|
Path to folder that contains cache files. |
'cache'
|
cache_nrows |
int
|
Number of rows to load from cache (None (default): load all rows). |
None
|
start |
str
|
Start-date for filtering posts. String format must be valid input for |
None
|
end |
str
|
End-date for filtering posts. String format must be valid input for |
None
|
get_metrics(level=None, returntype=None, unwrapped=False, select_func=set.intersection)
Get all available metrics that are defined for the communities. The
select_func
parameter is set to set.intersection
per
default, meaning that only those metrics are returned, that exist
for all communities. Metrics can be filtered by level
and
returntype
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
level |
None
|
||
returntype |
None
|
||
unwrapped |
'Unwrap' the returned metric functions from their |
False
|
|
select_func |
set.intersection
|
Returns:
Type | Description |
---|---|
dict of str:func metricname:metric |
get_preprocessors(level=None, returntype=None, unwrapped=False, select_func=set.intersection)
Get all available metrics that are defined for the communities. The
select_func
parameter is set to set.intersection
per
default, meaning that only those metrics are returned, that exist
for all communities. Metrics can be filtered by level
and
returntype
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
level |
None
|
||
returntype |
None
|
||
unwrapped |
'Unwrap' the returned metric functions from their |
False
|
|
select_func |
set.intersection
|
Returns:
Type | Description |
---|---|
dict of str:func metricname:metric |