'Copy a value from a column to a new one if a certain column contains a specific element pandas

I'm doing a program that has two dataframes from the following dataset: kaggle.com/varpit94/ethereum-data

One of them has a format for dates (YYYY-MM-DD), what I want to do is include the elements of the column Close2018-19 in the dataframe df2 to a new column with its respective months. For instance, if in the Date column I have 2018-01-16 then I want it's respective value from the column Close2018-19 to be saved in a new column called January2018-2019. If I'm not explaining myself too well I could redact again the problem, thanks in advance, here's the code:

import pandas as pd
import numpy as np
import copy
import matplotlib.pyplot as plt


df=pd.read_csv('ETH-USD.csv')


df['Average-H-L'] = df[['High', 'Low']].mean(axis=1)
df = df[['Date','Close','Average-H-L']]

df2018 = df[(df['Date'].str.contains("2018-"))]
df2018.columns = ['Date','Close2018','Average-H-L2018']
df2019 = df[(df['Date'].str.contains("2019-"))]
df2019.columns = ['Date','Close2019','Average-H-L2019']

df2 = pd.concat([df2018,df2019], axis=0, ignore_index=True)
df2['Close'] = df2[['Close2018', 'Close2019']].mean(axis=1)
df2['Average-H-L'] = df2[['Average-H-L2018', 'Average-H-L2019']].mean(axis=1)
df2 = df2[['Date','Close','Average-H-L']]
df2.columns = ['Date','Close2018-19','Average-H-L2018-19']

df2['Year'] = df2['Date'].str.split('-').str[0]


df2['January2018-2019']= df2['Date'].str.contains("-07-")

#result = pd.concat([df, df2], axis=1).corr()
#result
df2

Here's how the table currently looks like: enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source