whatstk.utils package¶
Submodules¶
whatstk.utils.chat_merge module¶
Merging chats.
Functions:
|
Merge several chats into a single one. |
- whatstk.utils.chat_merge.merge_chats(dfs: List[DataFrame]) DataFrame [source]¶
Merge several chats into a single one.
Can come in handy when you have old exports and new ones, and both have relevant data.
Note: The dataframes must have an index with the timestamps of the messages, as this is required to correctly sort and merge the chats.
- Parameters
dfs (List[pandas.DataFrame]) – List with the chats as DataFrames.
- Returns
pandas.DataFrame – Merged chat.
whatstk.utils.exceptions module¶
Library exceptions.
Exceptions:
Raised when hformat could not be found. |
|
Raised when regex match is not possible. |
whatstk.utils.gdrive module¶
Google Drive utils.
Warning
To load chats from google drive, install the library with the corresponding extension (ignore the
--upgrade
option if you haven’t installed the library):
pip install whatstk[gdrive] --upgrade
Functions:
|
Initialize GDrive credentials. |
- whatstk.utils.gdrive.gdrive_init(client_secret_file: str, encoding: str = 'utf8') None [source]¶
Initialize GDrive credentials.
This should only run once before reading a file from Google Drive the first time. Subsequent executions should run seamlessly.
To obtain client_secret_file, follow the instructions from: https://medium.com/analytics-vidhya/how-to-connect-google-drive-to-python-using-pydrive-9681b2a14f20
Notes
Additionally, make sure to add yourself in Test users, as noted in: https://stackoverflow.com/questions/65980758/pydrive-quickstart-and-error-403-access-denied
Select Desktop App instead of Web Application as the application type.
- Parameters
client_secret_file (str) – Path to clien_secret.json file (Created in Google Console).
encoding (str) – Encoding to use for UTF when reading/writing (ex. ‘utf-8’). List of Python standard encodings.
whatstk.utils.utils module¶
Utils.
Classes:
Access class constants using variable |
- class whatstk.utils.utils.ColnamesDf[source]¶
Bases:
object
Access class constants using variable
whatstk.utils.utils.COLNAMES_DF
.Example
Access constant
COLNAMES_DF.DATE
:>>> from whatstk.utils.utils import COLNAMES_DF >>> COLNAMES_DF.DATE 'date'
Attributes:
Date column
Message column
Message length column
Message type column
Username column
- DATE = 'date'¶
Date column
- MESSAGE = 'message'¶
Message column
- MESSAGE_LENGTH = 'message_length'¶
Message length column
- MESSAGE_TYPE = 'message_type'¶
Message type column
- USERNAME = 'username'¶
Username column
Module contents¶
Library generic utils.