Python and dataframe and datetime object -- 2

Cancelled Posted 3 years ago Paid on delivery
Cancelled Paid on delivery

I want to create a new variable New_variable in the following dataset.

The rule for the New_variable is: if a consequential row started within 1 or less from any previous rows' Start or End variables' values, then it should have valued the same otherwise incrementally increases by 1.

Existing Data:

ID Start End New_variable

A 1 1 1

A 0.8 8 1

A 4 4 1

A 18 19 2

B 1 1 1

B 4 6 2

Next, when adding new observations, it also should have the same rule as above, but it should not change the previous New_variable-s values, but add consequentially even the Start value is smaller than the very first row of existing data's start value, see below the desired output.

New Data:

ID Start End

A -5 0

A 6 6

A 10 11

A 23 23

C 1 2

The desired output should be as below:

Existing and New Data:

ID Start End New_variable

A -5 0 3

A 1 1 1

A 0.8 8 1

A 4 4 1

A 6 6 1

A 10 11 4

A 18 19 2

A 23 23 5

B 1 1 1

B 4 6 2

C 1 2 1

Python Software Architecture

Project ID: #27863026

About the project

8 proposals Remote project Active 3 years ago

8 freelancers are bidding on average $118 for this job

Fazeennazar

*** Python Dataframe Expert with Pandas *** I read your project description very carefully. I have a deep understanding and experience in the areas of python that you mentioned. I've previously worked on the similar More

$140 USD in 7 days
(92 Reviews)
6.0
CrazyProger

I'm a Python expert with rich experience. I read the job details extremely carefully. I can develop a Python script to create a new variable New_variable in the given dataset. I'm ready to do it now. I will wait fo More

$100 USD in 1 day
(17 Reviews)
5.3
PKonstiantyn

HI, I am experienced developer in the field of AI, ML, deep learning and Time series analysis (Algo Trading) and have been working as data scientist from last two years. I can handle task by using Python( Tensorflow, k More

$140 USD in 7 days
(18 Reviews)
4.9
youchian521

Hi Dear, I read your description carefully. I understood what you require me to do and I am filled with confidence that I can complete your project wonderfully. I have experience over 5+ years with Python and etc. I en More

$100 USD in 1 day
(4 Reviews)
2.8
eyadbas

Hi, sir. Thank you for sharing your project Python and dataframe and datetime object -- 2, and I would be very happy to help you with your business. Let me share you with my expertise in Python, Software Architecture a More

$155 USD in 2 days
(2 Reviews)
2.4