Addition and Subtraction on TimeDelta objects using Pandas - Python Last Updated : 29 Aug, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report TimeDelta module is used to represent the time in the pandas module and can be used in various ways. Performing operations like addition and subtraction are very important for every language but performing these tasks on dates and time can be very valuable. Operations on TimeDelta dataframe or series - 1) Addition - df['Result'] = df['TimeDelta1'] + df['TimeDelta2'] 2) Subtraction - df['Result'] = df['TimeDelta1'] - df['TimeDelta2'] Return: Return the dataframe after operations is performed. Example #1 : In this example, we can see that by using various operations on date and time, we are able to get the addition and subtraction on the dataframe having TimeDelta object values. Python3 # import pandas and numpy import pandas as pd import numpy as np # Perform addition operation a = pd.Series(pd.date_range('2020-8-10', periods=5, freq='D')) b = pd.Series([pd.Timedelta(days=i) for i in range(5)]) gfg = pd.DataFrame({'A': a, 'B': b}) gfg['Result'] = gfg['A'] + gfg['B'] print(gfg) Output : A B Result 0 2020-08-10 0 days 2020-08-10 1 2020-08-11 1 days 2020-08-12 2 2020-08-12 2 days 2020-08-14 3 2020-08-13 3 days 2020-08-16 4 2020-08-14 4 days 2020-08-18 Example #2 : Python3 # import pandas and numpy import pandas as pd import numpy as np # Perform addition operation a = pd.Series(pd.date_range('2020-8-10', periods=4, freq='D')) b = pd.Series([pd.Timedelta(days=i) for i in range(4)]) gfg = pd.DataFrame({'A': a, 'B': b}) gfg['Result'] = gfg['A'] - gfg['B'] print(gfg) Output : A B Result 0 2020-08-10 0 days 2020-08-10 1 2020-08-11 1 days 2020-08-10 2 2020-08-12 2 days 2020-08-10 3 2020-08-13 3 days 2020-08-10 Comment More infoAdvertise with us Next Article Python | Pandas TimedeltaIndex.asobject J jitender_1998 Follow Improve Article Tags : Python Python-pandas Python pandas-datetime Practice Tags : python Similar Reads How to add and subtract days using DateTime in Python? Pythonâs built-in datetime module provides powerful tools to work with dates and times. One of its common tasks is manipulating dates by adding or subtracting days, hours, minutes and more. It's key classes in the datetime module.NameDescriptiondateIt shows the date according to the Georgian calenda 3 min read How to add and subtract days using DateTime in Python? Pythonâs built-in datetime module provides powerful tools to work with dates and times. One of its common tasks is manipulating dates by adding or subtracting days, hours, minutes and more. It's key classes in the datetime module.NameDescriptiondateIt shows the date according to the Georgian calenda 3 min read Python | Pandas TimedeltaIndex.asobject Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas TimedeltaIndex.asobject attribute return object Index which contains boxed valu 2 min read Python | Pandas TimedeltaIndex.nanoseconds Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas TimedeltaIndex.nanoseconds attribute return the number of nanoseconds for each 2 min read Python | Pandas Timedelta.nanoseconds Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Timedelta is a subclass of datetime.timedelta, and behaves in a similar manner. It is 1 min read Python | Pandas TimedeltaIndex.set_names Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas TimedeltaIndex.set_names() function is used to set new names on the given Timed 2 min read Like