Working on a dataframe in Python 3 Pandas that requires a new column to be created. I have two similar columns with different length strings. The new column should return either column 1 or 2 that has a 13 character length. In excel I would write it as: c2=if(len(b2)=13,b2,a2) then copy the formula down.
The code I need interpreted is:
df = pd.read_csv("example15.csv")
#create a new column with if-then statment
df['13_digit_#'] = (df.column1 len = 13 or df.column2 len = 13)
How would I rewrite the last line? Thanks much!
Aucun commentaire:
Enregistrer un commentaire