mibiscreen.data
API reference
mibiscreen module for data handling.
check_data
Functions for data handling and standardization.
@author: Alraune Zech
check_columns(data_frame, standardize=False, reduce=False, verbose=True)
Function checking names of columns of data frame.
Function that looks at the column names and links it to standard names. Optionally, it renames identified column names to the standard names of the model.
data_frame: pd.DataFrame
dataframe with the measurements
standardize: Boolean, default False
Whether to standardize identified column names
reduce: Boolean, default False
Whether to reduce data to known quantities
verbose: Boolean, default True
verbosity flag
tuple: three list containing names of
list with identitied quantities in data (but not standardized names)
list with unknown quantities in data (not in list of standardized names)
list with standard names of identified quantities
Raises:
None (yet).
Example:
Todo’s: - complete list of potential contaminants, environmental factors - add name check for metabolites?
Source code in mibiscreen/data/check_data.py
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 |
|
check_data_frame(data_frame, sample_name_to_index=False, inplace=False)
Checking data on correct format.
Tests if provided data is a pandas data frame and provides column names. Optionally it sets the sample name as index.
Input
data_frame: pd.DataFrame
quantities for data analysis given per sample
sample_name_to_index: Boolean, default False
Whether to set the sample name to the index of the DataFrame
inplace: Boolean, default False
Whether to modify the DataFrame rather than creating a new one.
Output
data: pd.DataFrame
copy of given dataframe with index set to sample name
cols: list
List of column names
Source code in mibiscreen/data/check_data.py
check_units(data, verbose=True)
Function to check the units of the measurements.
data: pandas.DataFrames
dataframe with the measurements where first row contains
the units or a dataframe with only the column names and units
verbose: Boolean
verbose statement (default True)
col_check_list: list
quantities whose units need checking/correction
None (yet).
Example:
To be added.
Source code in mibiscreen/data/check_data.py
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 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
|
check_values(data_frame, inplace=False, verbose=True)
Function that checks on value types and replaces non-measured values.
data_frame: pandas.DataFrames
dataframe with the measurements (without first row of units)
inplace: Boolean, default False
Whether to modify the DataFrame rather than creating a new one.
verbose: Boolean
verbose statement (default True)
data_pure: pandas.DataFrame
Tabular data with standard column names and without units
None (yet).
Example:
To be added.
Source code in mibiscreen/data/check_data.py
standard_names(name_list, standardize=True, reduce=False, verbose=False)
Function transforming list of names to standard names.
Function that looks at the names (of e.g. environmental variables, contaminants, metabolites, isotopes, etc) and provides the corresponding standard names.
name_list: string or list of strings
names of quantities to be transformed to standard
standardize: Boolean, default False
Whether to standardize identified column names
reduce: Boolean, default False
Whether to reduce data to known quantities
verbose: Boolean, default True
verbosity flag
tuple: three list containing names of
list with identitied quantities in data (but not standardized names)
list with unknown quantities in data (not in list of standardized names)
list with standard names of identified quantities
Raises:
None (yet).
Example:
Todo’s: - complete list of potential contaminants, environmental factors - add name check for metabolites?
Source code in mibiscreen/data/check_data.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 |
|
standardize(data_frame, reduce=True, store_csv=False, verbose=True)
Function providing condensed data frame with standardized names.
Function is checking names of columns and renames columns, condenses data to identified column names, checks units and names sof data frame.
Function that looks at the column names and renames the columns to the standard names of the model.
data_frame: pandas.DataFrames
dataframe with the measurements
check_metabolites: Boolean, default False
whether to check on metabolites' values
reduce: Boolean, default True
whether to reduce data to known quantities (default True),
otherwise full dataframe with renamed columns (for those identifyable) is returned
store_csv: Boolean, default False
whether to save dataframe in standard format to csv-file
verbose: Boolean, default True
verbose statement
data_numeric, units: pandas.DataFrames
Tabular data with standardized column names, values in numerics etc
and table with units for standardized column names
None (yet).
Example:
Todo’s: - complete list of potential contaminants, environmental factors - add name check for metabolites? - add key-word to specify which data to extract (i.e. data columns to return)
Source code in mibiscreen/data/check_data.py
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 |
|
example_data
Example dat.
Measurements on quantities and parameters in groundwater samples used for biodegredation and bioremediation analysis.
@author: Alraune Zech
example_data(data_type='all', with_units=False)
Function provinging test data for mibiscreen data analysis.
data_type: string
Type of data to return:
-- "all": all types of data available
-- "set_env_cont": well setting, environmental and contaminants data
-- "setting": well setting data only
-- "environment": data on environmental
-- "contaminants": data on contaminants
-- "metabolites": data on metabolites
-- "isotopes": data on isotopes
-- "hydro": data on hydrogeolocial conditions
with_units: Boolean, default False
flag to provide first row with units
if False (no units), values in columns will be numerical
if True (with units), values in columns will be objects
pandas.DataFrame: Tabular data with standard column names
None
Example:
To be added!
Source code in mibiscreen/data/example_data.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 |
|
load_data
Functions for data I/O handling.
@author: Alraune Zech
load_csv(file_path=None, verbose=False, store_provenance=False)
Function to load data from csv file.
file_path: str
Name of the path to the file
verbose: Boolean
verbose flag
store_provenance: Boolean
To add!
data: pd.DataFrame
Tabular data
units: pd.DataFrame
Tabular data on units
ValueError: If `file_path` is not a valid file location
Example:
This function can be called with the file path of the example data as argument using:
>>> from mibiscreen.data import load_excel
>>> load_excel(example_data.csv)
Source code in mibiscreen/data/load_data.py
load_excel(file_path=None, sheet_name=0, verbose=False, store_provenance=False, **kwargs)
Function to load data from excel file.
file_path: str
Name of the path to the file
sheet_name: int
Number of the sheet in the excel file to load
verbose: Boolean
verbose flag
store_provenance: Boolean
To add!
**kwargs: optional keyword arguments to pass to pandas' routine
read_excel()
data: pd.DataFrame
Tabular data
units: pd.DataFrame
Tabular data on units
ValueError: If `file_path` is not a valid file location
Example:
This function can be called with the file path of the example data as argument using:
>>> from mibiscreen.data import load_excel
>>> load_excel(example_data.xlsx)
Source code in mibiscreen/data/load_data.py
names_data
Name specifications of data!
File containing name specifications of quantities and parameters measured in groundwater samples useful for biodegredation and bioremediation analysis
@author: A. Zech
set_data
Functions for data extraction and merging in preparation of analysis and plotting.
@author: Alraune Zech
compare_lists(list1, list2, verbose=False)
Checking overlap of two given list.
Input
list1: list of strings
given extensive list (usually column names of a pd.DataFrame)
list2: list of strings
list of names to extract/check overlap with strings in list 'column'
verbose: Boolean, default True
verbosity flag
Output
(intersection, remainder_list1, reminder_list2): tuple of lists
* intersection: list of strings present in both lists 'list1' and 'list2'
* remainder_list1: list of strings only present in 'list1'
* remainder_list2: list of strings only present in 'list2'
Example:
list1 = [‘test1’,’test2’] list2 = [‘test1’,’test3’]
([‘test1’],[‘test2’]['test3']) = compare_lists(list1,list2)
Source code in mibiscreen/data/set_data.py
determine_quantities(cols, name_list='all', verbose=False)
Determine quantities to analyse.
Input
cols: list
Names of quantities from pd.DataFrame)
name_ist: str or list, dafault is 'all'
either short name for group of quantities to use, such as:
- 'all' (all qunatities given in data frame except settings)
- 'BTEX' (for benzene, toluene, ethylbenzene, xylene)
- 'BTEXIIN' (for benzene, toluene, ethylbenzene, xylene,
indene, indane and naphthaline)
- 'all_cont' (for all contaminant in name list)
or list of strings with names of quantities to use
verbose: Boolean
verbose flag (default False)
Output
quantities: list
list of strings with names of quantities to use and present in data
Source code in mibiscreen/data/set_data.py
extract_data(data_frame, name_list, keep_setting_data=True, verbose=False)
Extracting data of specified variables from dataframe.
data_frame: pandas.DataFrames
dataframe with the measurements
name_list: list of strings
list of column names to extract from dataframe
keep_setting_data: bool, default True
Whether to keep setting data in the DataFrame.
verbose: Boolean
verbose flag (default False)
data: pd.DataFrame
dataframe with the measurements
Raises:
None (yet).
Example:
To be added.
Source code in mibiscreen/data/set_data.py
merge_data(data_frames_list, how='outer', on=[names.name_sample], clean=True, **kwargs)
Merging dataframes along columns on similar sample name.
data_frames_list: list of pd.DataFrame
list of dataframes with the measurements
how: str, default 'outer'
Type of merge to be performed.
corresponds to keyword in pd.merge()
{‘left’, ‘right’, ‘outer’, ‘inner’, ‘cross’}, default ‘outer’
on: list, default "sample_nr"
Column name(s) to join on.
corresponds to keyword in pd.merge()
clean: Boolean, default True
Whether to drop columns which are in all provided data_frames
(on which not to merge, potentially other settings than sample_name)
**kwargs: dict
optional keyword arguments to be passed to pd.merge()
data: pd.DataFrame
dataframe with the measurements
Raises:
None (yet).
Example:
To be added.
Source code in mibiscreen/data/set_data.py
unit_settings
Unit specifications of data!
File containing unit specifications of quantities and parameters measured in groundwater samples useful for biodegredation and bioremediation analysis.
@author: Alraune Zech