Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas subtract days from date

df['date1'] = df['date'] -  pd.to_timedelta(df['day'], unit='d')

print (df)
        date  day      date1
0 2015-10-10   23 2015-09-17
1 2015-12-19    9 2015-12-10
2 2016-03-05   34 2016-01-31
3 2016-09-17   23 2016-08-25
4 2016-04-30    2 2016-04-28
Comment

PREVIOUS NEXT
Code Example
Python :: localize timezone python 
Python :: random.shuffle 
Python :: how to plot pie chart in python 
Python :: 2 for loops at the same time in Python 
Python :: how to add column to np array 
Python :: Read XML file to Pandas DataFrame 
Python :: rename key in python dictionary 
Python :: python datetime weekday 
Python :: dataframe summary pandas 
Python :: difference between 2 timestamps pandas 
Python :: channel lock command in discord.py 
Python :: python list all files of directory in given pattern 
Python :: how to check if string is camelcase python 
Python :: pandas filter every column not null 
Python :: Python make directories recursively 
Python :: python use variable in another file 
Python :: button size tkinter 
Python :: move file python 
Python :: python plot 
Python :: pandas shift column down 
Python :: add to middle of list python 
Python :: isnumeric python 
Python :: python choose sample from list with replacement 
Python :: own labels for ticks matplotlib 
Python :: python datetime to seconds 
Python :: pep full form 
Python :: python decimal string 
Python :: df only take 2 columns 
Python :: km/h a m/s 
Python :: check if date is valid python 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =