Skip to content

DataFrame constructor doesn't always upconvert datetime #2810

Closed
@dalejung

Description

@dalejung
import pandas as pd
ind = pd.date_range(start="2000-01-01", freq="D", periods=10)
datetimes = [ts.to_pydatetime() for ts in ind]
dates = [ts.date() for ts in ind]

df = pd.DataFrame({'datetimes': datetimes, 'dates':dates})
df.dtypes
# datetimes : object
# dates: object

Seems to be an issue with having another object dtype in the constructor. In this case dates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions