joined = pd.DataFrame(dict(gvkey_x=[12343] * 6 + [12345] * 6 + [12346] * 6,
    year_y=list(range(2000, 2006)) * 3))
print(joined)
Filtering rows from dataframe on multiple conditions, getting ValueError