0

I want concatenate column: ['Time Period'] value and other string ('01-01') to new column: 'Date', with condition dt['Frequency']=='0'. Please help on this, I am new to python and learning scripting by some data processing.

dt.loc[dt['Frequency']=='0','Date']=dt['Time Period']+'01-01'

dt:
Frequency,Time Period,Date
0,2008
0,1961
2,2015Q1
3,2016M1
4
  • this may help you. Commented Jun 15, 2017 at 5:24
  • @Mohammed Yasin, No... Data frame having column 'Time Period' & I want to update it in another column as per condition + '01-01' Commented Jun 15, 2017 at 5:26
  • can you please show your DataFrame, that will help me to solve answer. Commented Jun 15, 2017 at 5:27
  • @ammy updated, please check Commented Jun 15, 2017 at 5:33

1 Answer 1

1
df["Date"] = df.loc[df['Frequency']==0, 'Time Period'] +"01-01"

Answer updated

Sign up to request clarification or add additional context in comments.

2 Comments

hey ammy can you explain what you've done here and what the original bug was? also don't think you need/want the first dt["Date"] = '
@ammy, done it: "Thanks for the feedback! Votes cast by those with less than 15 reputation are recorded, but do not change the publicly displayed post score."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.