I have following code to load dataframe
import pandas as pdufo = pd.read_csv('csv_path')
print(ufo.loc[[0,1,2] , :])
which gives following output, see the structure of the csv
City Colors Reported Shape Reported State Time
0 Ithaca NaN TRIANGLE NY 6/1/1930 22:00
1 Willingboro NaN OTHER NJ 6/30/1930 20:00
2 Holyoke NaN OVAL CO 2/15/1931 14:00
Now, I want to add an extra column based on existing column. I have a list which consist of indices of participating columns. It can be 0,1 or 0,2,3 or 1,2,3 anything.
I need to create it dynamically. I could come up with following
df1['combined'] = df1['City']+','+df1['State']
Putting index doesn't seem to work.
I want to join those columns. using ','.join()