1

I have been trying to look for this specific question but I cannot seem to find it so apologies in advance if there has been a previous thread asking the same question.

I have a df with football seasons but the format is a bit awkward (see below). I want to create a new column that goes from year 1929 to 2020 (see 'season_new')

   Season   season_new
0  1929     1929
1  1929-30  1930
2  1930-31  1931
3  1931-32  1932

Anyone can help me?

Many thanks

Frank Jimenez
  • 319
  • 1
  • 7

2 Answers2

1
df['season_new'] = df['Season'].apply(lambda d: d[:2] + d[-2:])
skullgoblet1089
  • 554
  • 4
  • 12
0

So you want to concatenate first 2 and last 2 characters of Season?

df['season_new'] = df['Season'].str[:2] + df['Season'].str[-2:]
Dan
  • 45,079
  • 17
  • 88
  • 157