'Add number in front of number in columns
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 ?
Solution 1:[1]
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"])
Solution 2:[2]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tim Biegeleisen |
| Solution 2 |
