Generation

generate functionMon, 06 Feb 2023

There is a df Pandas dataframe: date av_temp deviations country 1 1743-12-01 NaN NaN Åland 2 1744-01-01 NaN NaN Åland 3 1744-02-01 NaN NaN Åland 4 1744-03-01 NaN NaN Åland 9 1744-08-01 NaN NaN Åland Create a new column year from date in which you convert all date values to years. Example: 1744-01-01 Date column: 1744

df = pd.DataFrame({'date': ['1743-12-01', '1744-01-01', '1744-02-01', '1744-03-01', '1744-08-01'], 'av_temp': [0, 10, 20, 30, 40], 'deviations': [0, 10, 20, 30, 40], 'country': ['Åland', 'Åland', 'Åland', 'Åland', 'Åland'] })

Questions about programming?Chat with your personal AI assistant