Let's say I have a df, memories
| Year | Number_of_photos |
|---|---|
| 1990 | 27 |
| 1991 | 21 |
| 1992 | 39 |
| 1993 | 22 |
| 1994 | 10 |
| 1995 | 12 |
| 1996 | 22 |
| 1997 | 22 |
| 1998 | 40 |
| 1999 | 27 |
| 2000 | 18 |
| 2001 | 20 |
| 2002 | 18 |
| 2003 | 14 |
| 2004 | 33 |
| 2005 | 10 |
| 2006 | 24 |
| 2015 | 17 |
And I want to create a function that will spit out a data frame, where the user will input the start year and an integer, and that integer will determine the timeframes (i.e. if start year=1998 and int=4, then the timeframes will be 1998-2001, 2002-2005, 2006-2009,2010-2013, and 2014-2017). And within those timeframes, the function will generate the max Number_of_photos (i.e. 1998-2001 will generate 40, 2002-2005 will generate 33, 2006-2009 will generate 24, 2010-2013 will generate 'None', and lastly 2014-2017 will generate 17).
Any ideas on how I to define a function that will generate a data frame?
[In] def max_photos(df,start,integer):
[Out] |Timeframe|Max_Year|Max_Num_Photos|
|---------|--------|--------------|
|1998-2001| 1998 | 40 |
|2002-2005| 2004 | 33 |
|2006-2009| 2006 | 24 |
|2010-2013| None | None |
|2014-2017| 2015 | 17 |