ResourceCollection¶
- class xbrl_filings_api.ResourceCollection¶
Bases:
object
Collection of subresources of a
FilingSet
object.The subresources are all other
APIResource
subclasses exceptFiling
objects.This object may be iterated over, it defines
len()
as well as operatorin
. It may not, however, be accessed with an indexer (e.g.object[index]
) orreversed
.This collection is a view to the non-
Filing
resources of the parentFilingSet
, backreferenced in attributefilingset
.Entity
andValidationMessage
objects, as subclasses ofAPIResource
, have a custom__hash__()
method and their hash is based on a tuple of strings'APIResource'
, class attributeTYPE
, and objectapi_id
. This means that equality checks (==
) and related methods are based on this tuple. For example, when the actual entity object is not available, a fast way to check if an entity withapi_id
'123'
is included in the filing setfs
is:('APIResource', Entity.TYPE, '123') in fs.entities
Methods
get_pandas_data
([attr_names, ...])Get resources as data for
pandas.DataFrame
constructor.__hash__
()Return hash(self).
__repr__
()Return repr with
item_class
andlen(self)
.__str__
()Return str(self).
Attributes
List of available columns for resources of this type.
True if any resources of this type exist.
Reference to the parent
FilingSet
object.Type object of the items within.
- item_class: type[APIResource]¶
Type object of the items within.
- property exist: bool¶
True if any resources of this type exist.
This property is faster than
len(obj) != 0
.
- get_pandas_data(attr_names=None, *, strip_timezone=True, date_as_datetime=True, include_urls=False)¶
Get resources as data for
pandas.DataFrame
constructor.For example, a new dataframe can be instantiated for entities as follows:
import pandas as pd df = pd.DataFrame(data=filingset.entities.get_pandas_data())
If parameter
attr_names
is not given, most data attributes will be extracted.- Parameters:
attr_names (iterable of str, optional) – Valid attribute names of resource object.
strip_timezone (bool, default True) – Strip timezone information (always UTC) from
datetime
values.date_as_datetime (bool, default True) – Convert
date
values to naivedatetime
to be converted topandas.datetime64
by pandas.include_urls (bool, default False) – When parameter
attr_names
is not given, include attributes ending_url
.
- Returns:
data – Column names are the same as the attributes for resource of this type.
- Return type:
dict of {str: list of DataAttributeType}
See also
FilingSet.get_pandas_data
For
Filing
resources.
- __contains__(elem)¶
Return True if ResourceCollection contains
elem
.
- __iter__()¶
Iterate ResourceCollection.
- Return type:
- __repr__()¶
Return repr with
item_class
andlen(self)
.- Return type: