0

I have multiple pandas dataframes as follows:

import pandas as pd

# Create some dates
last_10 = pd.datetime.now().replace(microsecond=0) - pd.Timedelta('10H')

dates = pd.date_range(last_10, periods = 10, freq='H')

# Create first dataframe
N = 5
df1 = pd.DataFrame({'y': range(1, N + 1),'time': dates[0:N]})

# Create second dataframe with some overlap
df2 = pd.DataFrame({'y': range(1, N + 1),'time': dates[2:2+N]})

# Create a third dataframe
df3 = pd.DataFrame({'y': range(1, N + 1),'time': dates[5:5+N]})

Now what I want to do is vertically stack these dataframes to create a single data frame but I do not want sdduplicate time stamps i.e. if the to with the given time value already exists, I would like to just skip it.

Is there some pandas syntax to achieve this?

Luca
  • 10,458
  • 24
  • 107
  • 234

0 Answers0