I have a 20 x 4000 dataframe in python using pandas. Two of these columns are named Year and quarter. I'd like to create a variable called period that makes Year = 2000 and quarter= q2 into 2000q2
Can anyone help with that?
You can use .map function to join a string with a column in the dataframe. To combine two columns, you can simply use the ‘+’ operator.
For example:
dataframe["period"] = dataframe["Year"].map(str) + dataframe["quarter"]
Hope this answer helps.