Examples

In [1]:
import numpy as np
import pandas as pd
In [2]:
df1 = pd.DataFrame([[26.3, 78.5, 'high'],
                    [32, 85.5, 'high'],
                    [21, 68.5, 'medium'],
                    [30, 90, 'medium']],
    columns=['temp_celsius', 'temp_fahrenheit', 'windspeed'],
    index=pd.date_range(start='2019-02-12',
                        end='2019-02-15', freq='D'))
In [3]:
df1
Out[3]:
temp_celsius temp_fahrenheit windspeed
2019-02-12 26.3 78.5 high
2019-02-13 32.0 85.5 high
2019-02-14 21.0 68.5 medium
2019-02-15 30.0 90.0 medium
In [4]:
df2 = pd.DataFrame([[22, 'low'],
                    [28, 'low'],
                    [33.2, 'medium']],
    columns=['temp_celsius', 'windspeed'],
    index=pd.DatetimeIndex(['2019-02-12', '2019-02-13',
                            '2019-02-15']))
In [5]:
df2
Out[5]:
temp_celsius windspeed
2019-02-12 22.0 low
2019-02-13 28.0 low
2019-02-15 33.2 medium
In [6]:
df2.reindex_like(df1)
Out[6]:
temp_celsius temp_fahrenheit windspeed
2019-02-12 22.0 NaN low
2019-02-13 28.0 NaN low
2019-02-14 NaN NaN NaN
2019-02-15 33.2 NaN medium