Parent Doc: Python Documentation

API reference

Module/Function/AttributeDescriptionExample
pandas.testing.assert_frame_equalCheck that left and right DataFrame are equal.

This function is intended to compare two DataFrames and output any differences. It is mostly intended for use in unit tests. Additional parameters allow varying the strictness of the equality checks performed.

API reference
Especially handy when comparing floating point values, where we can leverage check_exact and relative or absolute tolerance (rtol or atol) parameters.

To compare without tolerance, we can just use `df1.equals(df2).
pandas.date_rangePandas
pandas.set_optionSets the value of the specified option.

Available options:
- compute
- display
- …

My most used ones are
- display.max_rows
- display.max_columns
- display.float_format

API reference
pandas.option.contextContext manager to temporarily set options in the with statement context.

Need to invoke as need to invoke as option_context(pat, val, [(pat, val), ...])

API reference
Pandas
pandas.mergeMerge DataFrame or named Series objects with a database-style join.

A named Series object is treated as a DataFrame with a single named column.

The join is done on columns or indexes. If joining columns on columns, the DataFrame indexes will be ignored. Otherwise if joining indexes on indexes or indexes on a column or columns, the index will be passed on. When performing a cross merge, no column specifications to merge on are allowed.

API reference

Examples

Generate date range

import pandas as pd
 
start_date_str = '2025-05-01'
end_date_str = '2025-05-15'
date_range = pd.date_range(start=start_date_str, end=end_date_str, freq='D')
date_range
DatetimeIndex(['2025-05-01', '2025-05-02', '2025-05-03', '2025-05-04',
               '2025-05-05', '2025-05-06', '2025-05-07', '2025-05-08',
               '2025-05-09', '2025-05-10', '2025-05-11', '2025-05-12',
               '2025-05-13', '2025-05-14', '2025-05-15'],
              dtype='datetime64[ns]', freq='D')
date_range_str = date_range.strftime('%Y-%m-%d')
date_range_str
Index(['2025-05-01', '2025-05-02', '2025-05-03', '2025-05-04', '2025-05-05',
       '2025-05-06', '2025-05-07', '2025-05-08', '2025-05-09', '2025-05-10',
       '2025-05-11', '2025-05-12', '2025-05-13', '2025-05-14', '2025-05-15'],
      dtype='object')

The difference is in the dtype of the two variables

print (date_range.dtype)
print(date_range_str.dtype)
datetime64[ns] 
object

Displaying all the rows in Pandas DF

from IPython.display import display
 
with pd.option_context('display.max_rows', None):
    display(pdf.head().T)