I have two Pandas DataFrames whose data from different sources, but both DataFrames have the same column names. When combined only one column will keep the name.
Like this:
speed_df = pd.DataFrame.from_dict({'ts': [0,1,3,4],'val': [5,4,2,1]})temp_df = pd.DataFrame.from_dict({'ts': [0,1,2],'val': [9,8,7]})
And I need to have a result like this:
final_df = pd.DataFrame.from_dict({'ts': [0,1,2,3,4],'speed': [5,4,NaN,1],'temp': [9,8,7,NaN,NaN]})
Later I will deal with empty cells (here filled with NaN) by copying the values of the previous valid value. And get something like this:
final_df = pd.DataFrame.from_dict({'ts': [0,1,2,3,4],'speed': [5,4,4,1],'temp': [9,8,7,7,7]})