Skip to content
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

time with am/pm #20

Open
Dpgaur1509 opened this issue Dec 12, 2023 · 2 comments
Open

time with am/pm #20

Dpgaur1509 opened this issue Dec 12, 2023 · 2 comments

Comments

@Dpgaur1509
Copy link

dates is converting '05/12/2023, 11:25\u202fam - ', like this while using 12 hrs time pattern with am/pm
and than data frame is also showing error

@PulsatingGenius
Copy link

from datetime import datetime

formatted_dates = []

for date_string in dates:
dt_object = datetime.strptime(date_string.strip('[]'), '%d/%m/%y, %I:%M:%S %p')
formatted_date = dt_object.strftime('%d/%m/%y, %I:%M:%S %p')
formatted_dates.append(formatted_date)

df = pd.DataFrame({'user_message': messages, 'message_date': formatted_dates})

df['message_date'] = pd.to_datetime(df['message_date'], format='%d/%m/%y, %I:%M:%S %p')

@ritik7545
Copy link

from datetime import datetime

formatted_dates = []

for date_string in dates: dt_object = datetime.strptime(date_string.strip('[]'), '%d/%m/%y, %I:%M:%S %p') formatted_date = dt_object.strftime('%d/%m/%y, %I:%M:%S %p') formatted_dates.append(formatted_date)

df = pd.DataFrame({'user_message': messages, 'message_date': formatted_dates})

df['message_date'] = pd.to_datetime(df['message_date'], format='%d/%m/%y, %I:%M:%S %p')

solve hua ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants