def validate_periods(periods):
if periods is not None:<EOL><INDENT>if lib.is_float(periods):<EOL><INDENT>periods = int(periods)<EOL><DEDENT>elif not lib.is_integer(periods):<EOL><INDENT>raise TypeError('<STR_LIT>'<EOL>.format(periods=periods))<EOL><DEDENT><DEDENT>return periods<EOL>
If a `periods` argument is passed to the Datetime/Timedelta Array/Index
constructor, cast it to an integer.

Parameters
----------
periods : None, float, int

Returns
-------
periods : None or int

Raises
------
TypeError
    if periods is None, float, or int