def to_period(self, freq=None, axis=<NUM_LIT:0>, copy=True):
new_data = self._data<EOL>if copy:<EOL><INDENT>new_data = new_data.copy()<EOL><DEDENT>axis = self._get_axis_number(axis)<EOL>if axis == <NUM_LIT:0>:<EOL><INDENT>new_data.set_axis(<NUM_LIT:1>, self.index.to_period(freq=freq))<EOL><DEDENT>elif axis == <NUM_LIT:1>:<EOL><INDENT>new_data.set_axis(<NUM_LIT:0>, self.columns.to_period(freq=freq))<EOL><DEDENT>else:  <EOL><INDENT>raise AssertionError('<STR_LIT>'.format(<EOL>ax=axis))<EOL><DEDENT>return self._constructor(new_data)<EOL>
Convert DataFrame from DatetimeIndex to PeriodIndex with desired
frequency (inferred from index if not passed).

Parameters
----------
freq : str, default
    Frequency of the PeriodIndex.
axis : {0 or 'index', 1 or 'columns'}, default 0
    The axis to convert (the index by default).
copy : bool, default True
    If False then underlying input data is not copied.

Returns
-------
TimeSeries with PeriodIndex