)
  * [ Resampling ](../resampling.html)
  * [ Style ](../style.html)
  * [ Plotting ](../plotting.html)
  * [ Options and settings ](../options.html)
  * [ Extensions ](../extensions.html)
  * [ Testing ](../testing.html)
  * [ Missing values ](../missing_value.html)

  * [ __ ](../../index.html)
  * [ API reference ](../index.html)
  * [ DataFrame ](../frame.html)
  * pandas.DataF... 

#  pandas.DataFrame.to_timestamp  #

DataFrame.  to_timestamp  (  _ freq  =  None  _ , _ how  =  'start'  _ , _
axis  =  0  _ , _ copy  =  None  _ )  [ [source]  ](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/frame.py#L12223-L12303) #

    

Cast to DatetimeIndex of timestamps, at _beginning_ of period.

Parameters  :

    

**freq** str, default frequency of PeriodIndex

    

Desired frequency.

**how** {âsâ, âeâ, âstartâ, âendâ}

    

Convention for converting period to timestamp; start of period vs. end.

**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.

Note

The  copy  keyword will change behavior in pandas 3.0. [ Copy-on-Write
](https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html) will be
enabled by default, which means that all methods with a  copy  keyword will
use a lazy copy mechanism to defer the copy and ignore the  copy  keyword. The
copy  keyword will be removed in a future version of pandas.

You can already get the future behavior and improvements through enabling copy
on write ` pd.options.mode.copy_on_write  =  True  `

Returns  :

    

DataFrame

    

The DataFrame has a DatetimeIndex.

Examples

    
    
    >>> idx = pd.PeriodIndex(['2023', '2024'], freq='Y')
    >>> d = {'col1': [1, 2], 'col2': [3, 4]}
    >>> df1 = pd.DataFrame(data=d, index=idx)
    >>> df1
          col1   col2
    2023     1      3
    2024     2      4
    

The resulting timestamps will be at the beginning of the year in this case

    
    
    >>> df1 = df1.to_timestamp()
    >>> df1
                col1   col2
    2023-01-01     1      3
    2024-01-01     2      4
    >>> df1.index
    DatetimeIndex(['2023-01-01', '2024-01-01'], dtype='datetime64[ns]', freq=None)
    

Using  freq  which is the offset that the Timestamps will have

    
    
    >>> df2 = pd.DataFrame(data=d, index=idx)
    >>> df2 = df2.to_timestamp(freq='M')
    >>> df2
                col1   col2
    2023-01-31     1      3
    2024-01-31     2      4
    >>> df2.index
    DatetimeIndex(['2023-01-31', '2024-01-31'], dtype='datetime64[ns]', freq=None)
    

[ __ previous  pandas.DataFrame.to_period  ](pandas.DataFrame.to_period.html
"previous page") [ next  pandas.DataFrame.tz_convert  __
](pandas.DataFrame.tz_convert.html "next page")

__ On this page

  * ` DataFrame.to_timestamp()  `

[ __ Show Source
](../../_sources/reference/api/pandas.DataFrame.to_timestamp.rst.txt)

© 2024, pandas via [ NumFOCUS, Inc. ](https://numfocus.org) Hosted by [
OVHcloud ](https://www.ovhcloud.com) .

Created using [ Sphinx ](https://www.sphinx-doc.org/) 7.2.6.  

Built with the [ PyData Sphinx Theme ](https://pydata-sphinx-
theme.readthedocs.io/en/stable/index.html) 0.14.4.