Python Pandas operate on row

Posted by wuha on Stack Overflow See other posts from Stack Overflow or by wuha
Published on 2014-05-30T08:56:44Z Indexed on 2014/05/30 9:26 UTC
Read the original article Hit count: 179

Filed under:
|
|

Hi my dataframe look like:

Store,Dept,Date,Sales
1,1,2010-02-05,245
1,1,2010-02-12,449
1,1,2010-02-19,455
1,1,2010-02-26,154
1,1,2010-03-05,29
1,1,2010-03-12,239
1,1,2010-03-19,264

Simply, I need to add another column called '_id' as concatenation of Store, Dept, Date like "1_1_2010-02-05", I assume I can do it through df['id'] = df['Store'] +'' +df['Dept'] +'_'+df['Date'], but it turned out to be not.

Similarly, i also need to add a new column as log of sales, I tried df['logSales'] = math.log(df['Sales']), again, it did not work.

© Stack Overflow or respective owner

Related posts about python

Related posts about pandas