subtraction

Is there a way to subtract from the date a year specified in another column in python?

Is there a way to subtract from the date a year specified in another column in python? Question: Today I have confronted some challenges. This is an example dataset: example = { "a": [‘1/1/1954 14:14′,’2/14/2001 2:00’ , ‘2/15/2002 12:00’], "b": [1936,1996,1960], } #load into df: example = pd.DataFrame(example) print(example) What I was trying to do …

Total answers: 1

How to choose specific values in a csv file with python

How to choose specific values in a csv file with python Question: I need to be able to do the subtraction between the bigger and smaller positive number in ColumnB that have ColumnA=1,ColumnC=0. (I wrote them between ** to make it clearer) I have something like this in my csv file but I have a …

Total answers: 1

Calculate/subtract the difference between two date time columns

Calculate/subtract the difference between two date time columns Question: How can we calculate the difference between two date time columns in Python Pandas? Below is the sample table: starttime endtime 06:10:42 AM 06:20:00 AM 03:45:54 AM 03:52:27 AM Desired result: starttime endtime total 06:10:42 AM 06:20:00 AM 0:10:00 03:45:54 AM 03:52:27 AM 0:06:33 I tried …

Total answers: 2

Subtracting elements from sorted dictionary in Python

Subtracting elements from sorted dictionary in Python Question: I have a sorted dictionary (here the bids of an order book) with the following form, where the items in the parentheses are {price: amount} and sorted. bids = SortedDict({0.0005: 11.0, 0.006: 10.0, 0.01: 28.6, 0.0105: 21.8, 0.012: 25.1}) I also know my own quotes, which are: …

Total answers: 3

Subtract two columns and show outcome in the next line

Subtract two columns and show outcome in the next line Question: I would like to get a cumulative sum of X and also subtract X-Y in each column. The remainder should be found and added to the next row. I would also like the count to reset to 0 at the end of every month. …

Total answers: 2

Subtract last timestamp from first timestamp for each Id in Pandas Dataframe

Subtract last timestamp from first timestamp for each Id in Pandas Dataframe Question: I have a dataframe (df) with the following structure: retweet_datetime tweet_id tweet_datetime 2020-04-24 03:33:15 85053699 2020-04-24 02:28:22 2020-04-24 02:43:35 85053699 2020-04-24 02:28:22 2020-04-18 04:24:03 86095361 2020-04-18 00:06:01 2020-04-18 00:19:08 86095361 2020-04-18 00:06:01 2020-04-18 00:18:38 86095361 2020-04-18 00:06:01 2020-04-18 00:07:08 86095361 2020-04-18 00:06:01 …

Total answers: 2

Count of Year in Python

Count of Year in Python Question: How can I find count of year in python from certain date and a date since people opened an account (CRDACCT_DTE_OPEN)? The certain date (MIS_DATE) is 2021-03-01 with format= ‘%Y%m%d’. The dataset given below: import pandas as pd df = pd.DataFrame( { "MIS_DATE": ["2018-03-02", "2020-03-26", "2019-08-17", "2019-08-17", "2019-08-19"], "CRDACCT_DTE_OPEN": …

Total answers: 3

Set difference versus set subtraction

Set difference versus set subtraction Question: What distinguishes – and .difference() on sets? Obviously the syntax is not the same, one is a binary operator, the other is an instance method. What else? s1 = set([1,2,3]) s2 = set([3,4,5]) >>> s1 – s2 set([1, 2]) >>> s1.difference(s2) set([1, 2]) Asked By: David542 || Source Answers: …

Total answers: 3