Performing divison on timedelta object in python?

0 votes
How do I divide a timedelta object?
Aug 13, 2019 in Python by Fata
• 1,050 points
67 views

1 answer to this question.

0 votes

Refer the following piece of code:

e1=datetime.timedelta(days=32, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=4, weeks=8)
e2=datetime.timedelta(days=5, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=4, weeks=8)
e3=e1-e2
e4=e3//3
print(e4)

OUTPUT:

9 days, 0:00:00
answered Aug 13, 2019 by Wajiha
• 1,950 points

Related Questions In Python

0 votes
1 answer

How can I convert a list of dictionaries from a CSV into a JSON object in Python?

You could try using the AST module. ...READ MORE

answered Apr 17, 2018 in Python by anonymous
1,905 views
0 votes
1 answer

Size of an object in Python

Use sys.getsizeof() function: >>> import sys >>> s = ...READ MORE

answered May 25, 2018 in Python by Nietzsche's daemon
• 4,260 points
162 views
0 votes
1 answer

Convert string list of dict from csv into JSON object in python

You can use the ast module Ex: import ast s = """[{'10': ...READ MORE

answered Sep 12, 2018 in Python by Priyaj
• 57,640 points
1,230 views
0 votes
1 answer

How can I print variable and string on same line in Python?

Use , to separate strings and variables while printing: print ...READ MORE

answered Sep 17, 2018 in Python by Priyaj
• 57,640 points
1,005 views
0 votes
1 answer

Convert string list of dict from csv into JSON object in python

You can use the ast module Ex: import ast s = """[{'10': ...READ MORE

answered Sep 24, 2018 in Python by Priyaj
• 57,640 points
128 views
0 votes
1 answer

How to convert date string to date object in python?

Use this :-  >>> datetime.datetime.strptime('2405201 ...READ MORE

answered Oct 22, 2018 in Python by Priyaj
• 57,640 points
5,895 views
0 votes
0 answers

How to mix read() and write() on Python files in Windows

It appears that a write() immediately following a read() on a ...READ MORE

Oct 23, 2018 in Python by Aryya
• 500 points
139 views
0 votes
1 answer

How to convert a Pandas GroupBy object to DataFrame in Python

g1 here is a DataFrame. It has a hierarchical index, ...READ MORE

answered Nov 12, 2018 in Python by Nymeria
• 3,520 points
21,287 views
0 votes
1 answer

What is timedelta in python?

It represents a duration which is basically ...READ MORE

answered Aug 7, 2019 in Python by Wajiha
• 1,950 points
87 views
0 votes
1 answer

Slicing a list using a variable, in Python

Yes its possible. Use the following piece ...READ MORE

answered Jul 2, 2019 in Python by Wajiha
• 1,950 points
73 views