Question:

My machine only sends an update to the cloud if the value of a variables has changed. As a result there are empty entries in my analytics query.

How can i fill up these empty cells in my data (upwards/downwards)?


Solution:

To easily solve this problem we can use the "fillna" methode which is provided for DataFrame/Series pandas objects.


#loading necessary packages
import pandas as pd
import numpy as np

#method='bfill' fills the columns from bottom to top; method='ffill# fills from top to bottom
df = df.fillna(method = 'bfill')


The only parametere which needs to be specified is:

methode … „bfill“ fills columns from bottom to top, „ffill“ fills the columns from top to bottom