Skip to content

ENH: Convert a string column of times (hour:min) to datetime without date #46291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Hadi2525 opened this issue Mar 9, 2022 · 1 comment
Closed
Labels
Enhancement Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@Hadi2525
Copy link

Hadi2525 commented Mar 9, 2022

I have the following df:

import pandas as pd
df = pd.DataFrame(['12:53','13:00','13:11','14:45'],columns = 'Time')
df = pd.to_datetime(df, format = '%H:%M')

The output is:

>>> df
Time:
1900-01-01 12:53:00
1900-01-01 13:00:00
1900-01-01 13:11:00
1900-01-01 14:45:00

Is there a way to remove dates from rows in df? Perhaps, a method or attribute be added like date = None?

@Hadi2525 Hadi2525 added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 9, 2022
@norisa118 norisa118 removed their assignment Mar 31, 2022
@mroeschke
Copy link
Member

There's pandas.core.tools.to_time that can parse times which seems to be what you want. Needs to be exposed properly which is referenced in #11947 so closing in favor of that issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

3 participants