Answers for "select date pandas"

0

pandas query on datetime

from time import datetime

date_start = datetime(year_start, month_start, day_start)
date_end = datetime(year_end, month_end, day_end)

# df is your pandas dataframe
sel = df[(df['timestamp'] >= date_start) &
         (df['timestamp'] <= date_end)]

# tested with
# python 3.9.4
# pandas 1.3.2
Posted by: Guest on September-06-2021
-1

extract DATE from pandas

import pandas as pd

d='2015-01-08 22:44:09' 
date=pd.to_datetime(d).date()
print(date)
Posted by: Guest on May-17-2021

Python Answers by Framework

Browse Popular Code Answers by Language