I have a dataframe in which I need to add a column based on a certain condition. I am successfully doing this([How to have list's elements as a condition in np.where()?](https://stackoverflow.com/questions/55954111/how-to-have-lists-elements-as-a-condition-in-np-where)). However, when I apply the same logic twice, it does not work.

my datframe is:

```
period period_type
JAN16 month
JAN16 YTD
2017 2017

```

What I want instead is: `2017 annual`.
However, I get `annual` for all the values, i.e. months, YTD etc get changed to annual.
Code block :

```
def add_period_type(df):
    months = ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC']
    m = df.period.str.startswith(tuple(months))
    df['period_type'] = np.where(m, 'month', df.period.str.split().str[0])
    df.loc[~m, 'period'] = df.loc[~m, 'period'].str.split().str[1]
    df["period"] = df["period"].combine_first(df["period_type"])
    years = [str(x) for x in range(2000, 2100)]
    y = df.period.str == (tuple(years))
    print(y)
    df['period_type'] = np.where(y, 'annual', df.period_type.str)
    return df

```

The first 3-4 lines add a new column `period_type`. I, then, want to modify this column a bit based on the aforementioned condition(check whether the value is a year and if it is, assigns annual to the period\_type. Instead, thbis code is not working, it assigns `annual` to all.