Reputation: 13
i'm fairly new to pandas, i downloaded an excel file which contains public law enforcement data, i wanted to concatenate a date (M/D/Y) column with another column that only has texts and add them in a new column. the columns that i want to concatenate is called 'Primary Offense Description' & the other column is called 'Occurred Date'.
Feel free to ask for the excel file & i shall upload it.
Upvotes: 1
Views: 3954
Reputation: 490
here is an example dataset,
df1 = pd.DataFrame({
"Date" : ['2013-11-24', '2013-11-24', '2013-11-24', '2013-11-24'],
"Fruit" : ['Banana', 'Orange', 'Apple', 'Celery'],
"Num" : [22.1, 8.6, 7.6, 10.2],
"Color" : ['Yellow', 'Orange', 'Green', 'Green']
})
the following line of code will create for you new column named "Combination" in the dataset which combine column Date & Color :
df1["Combination"] = df1["Date"] + df1["Color"]
Upvotes: 1