API reference
pd.testing
Test utilities for comparing Series and DataFrames. Mirrors pandas.testing.
| Name | Summary |
|---|---|
assert_series_equal | Check that two Series are equal. Raises AssertionError if not. Supports check_dt |
assert_frame_equal | Check that two DataFrames are equal. Raises AssertionError if not. |
assert_index_equal | Check that left and right Index objects are equal. |
AssertionError | Error class thrown when assertions fail. Extends the built-in Error class. |
assert_series_equal
#assert_series_equal(left, right, options?)
Check that two Series are equal. Raises AssertionError if not. Supports check_dtype, check_names, check_exact, rtol, atol.
Parameters
leftSeries- Left Series.
rightSeries- Right Series.
options?{ check_dtype?, rtol?, atol?, check_exact? }- Comparison options.
Returns
void
Example
TypeScript
import { assert_series_equal } from 'pandas-ts';
assert_series_equal(new Series([1, 2, 3]), new Series([1, 2, 3])); // passes
assert_series_equal(new Series([1.0]), new Series([1.0000001])); // passes (within rtol)assert_frame_equal
#assert_frame_equal(left, right, options?)
Check that two DataFrames are equal. Raises AssertionError if not.
Returns
void
Example
TypeScript
import { assert_frame_equal } from 'pandas-ts';
const a = new DataFrame({ x: [1, 2] });
assert_frame_equal(a, a); // passesassert_index_equal
#assert_index_equal(left, right, options?)
Check that left and right Index objects are equal.
Returns
void
Example
TypeScript
import { assert_index_equal } from 'pandas-ts';
assert_index_equal(['a','b','c'], ['a','b','c']); // passesAssertionError
#class AssertionError extends Error
Error class thrown when assertions fail. Extends the built-in Error class.
Returns
AssertionError
Example
TypeScript
import { AssertionError } from 'pandas-ts';
try {
assert_series_equal(new Series([1]), new Series([2]));
} catch (e) {
e instanceof AssertionError; // => true
}