<jupyter_start><jupyter_text>Creating a UserKey Class Instance and Understanding StatisticsThis notebook depends only on the package `factiva-core` which implements authentication operations against Dow Jones APIs. Additionally it can get activity for the specified user key like historical Snapshots or Streams.In this notebook...* [Dependencies and Initialisation](Dependencies-and-Initialisation)* [The UserKey Class](The-UserKey-Class)* [Snapshot History](Snapshot-History)* [Stream History](Stream-History)  Dependencies and InitialisationImport statements and environment initialisation using the package `dotenv`. More details in the [Configuration notebook](0.2_configuration.ipynb).<jupyter_code>from factiva.core import UserKey
from dotenv import load_dotenv
load_dotenv()
print('Done!')<jupyter_output>Done!<jupyter_text>The UserKey ClassThe UserKey class has two parameters:- **key**: str, optional. (default None)        String containing the 32-character long APi Key. If not provided, the        constructor will try to obtain its value from the FACTIVA_USERKEY        environment variable.- **stats**: bool, optional (Default: False)        Indicates if user data has to be pulled from the server. This operation        fills account detail properties along with maximum, used and remaining        values. It may take several seconds to complete.       Examples:```Python Gets the key value from the FACTIVA_USERKEY env variable. Do not load statistics.u = UserKey() Uses the provided key value. Load statistics.u = UserKey(key='<KEY>', stats=True)```<jupyter_code>u = UserKey(stats=True)
u<jupyter_output><empty_output><jupyter_text>Extraction HistoryGets/Shows the history of Snapshot objects for the given UserKey.- **get_extractions()**:        Returns a Pandas DataFrame with the full list of streams.- **show_extractions(updates=False)**:        Prints the list of extractions for the UserKey. By default        it filters the list to only initial Extractions (updates=False).        If updates=True, the full list of initial and updates        (additions, replacements, deletions) is displayed.<jupyter_code># eh = u.get_extractions()
u.show_extractions(updates=False)<jupyter_output>current_state format extraction_type snapshot_sid update_id
0   JOB_STATE_DONE   avro       documents   0pjfkz33ra      None
1   JOB_STATE_DONE   json       documents   0snv7pjx1a      None
2   JOB_STATE_DONE    csv       documents   0udvglt9xy      None
3   JOB_STATE_DONE   avro       documents   0zkwjps778      None
4   JOB_STATE_DONE   avro       documents   1nmayfqfnm      None
..             ...    ...             ...          ...       ...
69  JOB_STATE_DONE   avro       documents   ykefgy2ssu      None
70  JOB_STATE_DONE   avro       documents   ywk2wdd9my      None
71  JOB_STATE_DONE   avro       documents   ze9xq88syg      None
72  JOB_STATE_DONE   json       documents   zonrtw2hbe      None
73  JOB_STATE_DONE   avro       documents   zpxgqyrqgr      None

[72 rows x 5 columns]<jupyter_text>To get details about a particular Snapshot, the best option is creating a new Snapshot object using the Snapshot Short ID (`snapshot_sid`). In this case this value is already in the DataFrame, so the index number (e.g. `21`) is used to reference the exact item. A sample code looks like this:```Pythonfrom factiva.news import Snapshots = Snapshot(user_key=u, snapshot_id=e.loc[3, 'snapshot_sid'])s```  Stream HistoryGets/Shows all historical and currently running Stream instances. There are two functions that can be used for this purpose:- **get_streams()**:        Returns a Pandas DataFrame with the full list of streams.- **show_streams(running=True)**:        Prints the list of streams for the UserKey. By default it        filters the list to only those running stream instances        (running=True). If running=False, the full list of cancelled,        failed and running streams is displayed.<jupyter_code># sh = u.get_streams()
u.show_streams(running=True)<jupyter_output>job_status   stream_id stream_type subscriptions
33  JOB_STATE_RUNNING  auy761fkho      stream            []
{'fraction_non_alphanumeric': 0.06642335766423357, 'fraction_numerical': 0.012165450121654502, 'mean_word_length': 3.7416378316032297, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '659520', 'license': 'MIT', 'n_tokens_mistral': 1174, 'n_tokens_neox': 1133, 'n_words': 432, 'path': '1.1_user_statistics.ipynb', 'repo_name': 'dowjones/factiva-sample-notebooks', 'size': '4137'}