DataSource Abstract
API Classes
Found a method here you want to use? The API Classes have method pass-through so just call the method on the DataSource API Class and voilĂ it works the same.
The DataSource Abstract class is a base/abstract class that defines API implemented by all the child classes (currently just AthenaSource but later RDSSource, FutureThing ).
DataSourceAbstract: Abstract Base Class for all data sources (S3: CSV, JSONL, Parquet, RDS, etc)
DataSourceAbstract
Bases: Artifact
Source code in src/sageworks/core/artifacts/data_source_abstract.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
|
column_types: list[str]
abstractmethod
property
Return the column types for this Data Source
columns: list[str]
abstractmethod
property
Return the column names for this Data Source
database: str
property
Get the database for this Data Source
table: str
property
Get the base table name for this Data Source
__init__(data_uuid, database='sageworks', **kwargs)
DataSourceAbstract: Abstract Base Class for all data sources Args: data_uuid(str): The UUID for this Data Source database(str): The database to use for this Data Source (default: sageworks)
Source code in src/sageworks/core/artifacts/data_source_abstract.py
column_details()
Return the column details for this Data Source
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
The column details for this Data Source |
column_stats(recompute=False)
abstractmethod
Compute Column Stats for all the columns in a DataSource Args: recompute (bool): Recompute the column stats (default: False) Returns: dict(dict): A dictionary of stats for each column this format NB: String columns will NOT have num_zeros and descriptive stats {'col1': {'dtype': 'string', 'unique': 4321, 'nulls': 12}, 'col2': {'dtype': 'int', 'unique': 4321, 'nulls': 12, 'num_zeros': 100, 'descriptive_stats': {...}}, ...}
Source code in src/sageworks/core/artifacts/data_source_abstract.py
correlations(recompute=False)
abstractmethod
Compute Correlations for all the numeric columns in a DataSource
Parameters:
Name | Type | Description | Default |
---|---|---|---|
recompute
|
bool
|
Recompute the column stats (default: False) |
False
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dictionary of correlations for each column in this format {'col1': {'col2': 0.5, 'col3': 0.9, 'col4': 0.4, ...}, 'col2': {'col1': 0.5, 'col3': 0.8, 'col4': 0.3, ...}} |
Source code in src/sageworks/core/artifacts/data_source_abstract.py
descriptive_stats(recompute=False)
abstractmethod
Compute Descriptive Stats for all the numeric columns in a DataSource Args: recompute (bool): Recompute the descriptive stats (default: False) Returns: dict(dict): A dictionary of descriptive stats for each column in the form {'col1': {'min': 0, 'q1': 1, 'median': 2, 'q3': 3, 'max': 4}, 'col2': ...}
Source code in src/sageworks/core/artifacts/data_source_abstract.py
details()
Additional Details about this DataSourceAbstract Artifact
Source code in src/sageworks/core/artifacts/data_source_abstract.py
execute_statement(query)
abstractmethod
Execute an SQL statement that doesn't return a result Args: query(str): The SQL statement to execute
expected_meta()
DataSources have quite a bit of expected Metadata for EDA displays
Source code in src/sageworks/core/artifacts/data_source_abstract.py
get_database()
num_columns()
abstractmethod
num_rows()
abstractmethod
onboard()
This is a BLOCKING method that will onboard the data source (make it ready)
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the DataSource was onboarded successfully |
Source code in src/sageworks/core/artifacts/data_source_abstract.py
outliers(scale=1.5)
abstractmethod
Return a DataFrame of outliers from this DataSource
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scale
|
float
|
The scale to use for the IQR (default: 1.5) |
1.5
|
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: A DataFrame of outliers from this DataSource |
Notes
Uses the IQR * 1.5 (~= 2.5 Sigma) method to compute outliers The scale parameter can be adjusted to change the IQR multiplier
Source code in src/sageworks/core/artifacts/data_source_abstract.py
query(query)
abstractmethod
Query the DataSourceAbstract Args: query(str): The SQL query to execute
ready()
Is the DataSource ready?
Source code in src/sageworks/core/artifacts/data_source_abstract.py
recompute_stats()
This is a BLOCKING method that will recompute the stats for the data source
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the DataSource stats were recomputed successfully |
Source code in src/sageworks/core/artifacts/data_source_abstract.py
sample()
abstractmethod
Return a sample DataFrame from this DataSourceAbstract
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: A sample DataFrame from this DataSource |
set_computation_columns(computation_columns, recompute_stats=True)
Set the computation columns for this Data Source
Parameters:
Name | Type | Description | Default |
---|---|---|---|
computation_columns
|
list[str]
|
The computation columns for this Data Source |
required |
recompute_stats
|
bool
|
Recomputes all the stats for this Data Source (default: True) |
True
|
Source code in src/sageworks/core/artifacts/data_source_abstract.py
set_display_columns(diplay_columns)
Set the display columns for this Data Source
Parameters:
Name | Type | Description | Default |
---|---|---|---|
diplay_columns
|
list[str]
|
The display columns for this Data Source |
required |
Source code in src/sageworks/core/artifacts/data_source_abstract.py
smart_sample()
abstractmethod
Get a SMART sample dataframe from this DataSource Returns: pd.DataFrame: A combined DataFrame of sample data + outliers
value_counts(recompute=False)
abstractmethod
Compute 'value_counts' for all the string columns in a DataSource Args: recompute (bool): Recompute the value counts (default: False) Returns: dict(dict): A dictionary of value counts for each column in the form {'col1': {'value_1': X, 'value_2': Y, 'value_3': Z,...}, 'col2': ...}
Source code in src/sageworks/core/artifacts/data_source_abstract.py
view(view_name)
Return a DataFrame for a specific view Args: view_name (str): The name of the view to return Returns: pd.DataFrame: A DataFrame for the specified view