janitor.to_datetime

janitor.to_datetime(df: pandas.core.frame.DataFrame, column_name: Hashable, **kwargs) → pandas.core.frame.DataFrame[source]

Method-chainable to_datetime.

This method mutates the original DataFrame.

Functional usage syntax:

df = to_datetime(df, 'col1', format='%Y%m%d')

Method chaining syntax:

import pandas as pd
import janitor
df = pd.DataFrame(...).to_datetime('col1', format='%Y%m%d')
Parameters:
  • df – A pandas DataFrame.
  • column_name – Column name.
  • kwargs – provide any kwargs that pd.to_datetime can take.
Returns:

A pandas DataFrame with updated datetime data.