2
df = pd.DataFrame({'a' : np.random.randn(10), 
               'b' : np.random.randn(10), 
               'c' : np.random.randn(10)})
log_sum = np.log(np.abs(df["a"] + df['b'] + df['c']))
print log_sum
df.assign(log_sum=log_sum)
df.head()

I get the error:

AttributeError: 'DataFrame' object has no attribute 'assign'

2
  • 2
    Is the statement "New in version 0.16.0." relevant? Commented Jan 23, 2016 at 4:38
  • 1
    And you can always easily do df['log_sum] = log_sum Commented Jan 23, 2016 at 12:13

1 Answer 1

3

You must be using older version of Pandas,

assign method is introduced in Version 0.16.0, doc ref

you can check your pandas version using

import pandas
pandas.__version__ 

upgrade pandas-

pip install --upgrade pandas
Sign up to request clarification or add additional context in comments.

Comments

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.