I have this example columns
year_short
89
99
97
87
98
00
02
05
10
11
20
22
what I want to do is to make that column into like this
year_long
1989
1999
1997
1987
1998
2000
2002
2005
2010
2011
2020
2022
is it possible to make like that ?
CodePudding user response:
You could use the logic that any two digit year which is less than 25 belongs to the 2000
century, while any value greater than or equal to 25 belongs to the 1900
century:
df["year_long"] = np.where(df["year_short"] < 25, 2000 df["year_short"], 1900 df["year_short"])
CodePudding user response:
Apologies, this is for Excel, should be similar in Numbers though, I will delete unless it may help others.
So perhaps:
=if(A2>22,1900 A2,2000 A2)
You may want greater than 23 or 30, depends on your data.