Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python set day of date to 1

from datetime import datetime

your_date = datetime.strptime('26 June 2021', '%d %b %Y')
# Using the .replace() method:
newdatetime = your_date.replace(day=1)
# 2021-06-01 00:00:00
Comment

PREVIOUS NEXT
Code Example
Python :: loop throughthe key and the values of a dict in python 
Python :: how to split a string by character in python 
Python :: how to display printed values without scientific notation python 
Python :: how to iterate over columns of pandas dataframe 
Python :: create dictionary from string python 
Python :: show columns pandas 
Python :: scaling data 
Python :: only keep rows of a dataframe based on a column value 
Python :: import numpy financial python 
Python :: selenium open inspect 
Python :: leap year python 
Python :: pdf to csv 
Python :: pathlib path get filename with extension 
Python :: delete tuple from list 
Python :: pandas df filter by time hour 
Python :: check if a list contains any item from another list python 
Python :: 3 dimensional array numpy 
Python :: replace key of dictionary python 
Python :: python diagonal sum 
Python :: pandas convert column to datetime 
Python :: python keep value recursive function 
Python :: iterate over dictionary django 
Python :: dataclass default list 
Python :: how to get time in python 
Python :: qfiledialog python save 
Python :: import file in parent directory python 
Python :: capwords python 
Python :: print multiple lines python 
Python :: how to know the python pip module version 
Python :: train test split sklearn 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =