Dataframe
Helpers for dealing with pandas.DataFrames
_fix_integer_dtypes(df)
Since some version, pandas can not infer in assert_frame_equals Int64 as int64
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
A dataframe, that will behave all int types as int64 |
required |
Source code in bquest/dataframe.py
34 35 36 37 38 39 40 |
|
assert_frame_equal(left, right, **kwargs)
Asserts that two dataframes are equal regardless of their order of rows
Parameters:
Name | Type | Description | Default |
---|---|---|---|
left
|
DataFrame
|
A dataframe, usually the result of a function under test |
required |
right
|
DataFrame
|
Another dataframe, usually what we expect in a test |
required |
**kwargs
|
Any
|
Keyword arguments of pandas.testing.assert_frame_equal https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.testing.assert_frame_equal.html |
{}
|
Source code in bquest/dataframe.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
standardize_frame_numerics(df, float_precision=2)
Standardizes numerics inside a dataframe to facilitate comparison between dataframes with respect to meaningful differences.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
Pandas dataframe to be standardized |
required |
float_precision
|
int
|
level of precision for rounding floats |
2
|
Returns:
Type | Description |
---|---|
DataFrame
|
Standardized dataframe |
Source code in bquest/dataframe.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|