Skip to content
Advertisement

Python – How to clean time series data

I have a df which looks like this:

JavaScript

enter image description here

I’m trying to create a new column called ‘First_Contract’:

  1. ‘First_Contract’ needs to take the third-last value of ‘Sep’ column, before ‘Sep’column reaches NaN.
  2. The subsequent values need to be filled with ‘Dec’ column values.

Desired output:

JavaScript

enter image description here

How do I go about to achieve this?

Advertisement

Answer

Let us do it step by step

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement