O'Reilly logo

Hands-On Data Analysis with NumPy and pandas by Curtis Miller

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Arithmetic with DataFrames

Arithmetic between DataFrames bears some similarity with series or NumPy array arithmetic. Arithmetic between two DataFrames, or a DataFrame and a scaler, works as you'd expect; but arithmetic between a DataFrame and a series requires care. What must be kept in mind is that arithmetic involving a DataFrame applies to the columns of the DataFrame first, and then it applies across the rows of the DataFrame. So, columns in the DataFrame will be matched with either the single scalar, elements of the series with indices of the same name as the columns, or columns in the other involved DataFrame. If there are elements of either the series or either DataFrame that cannot find a mate, then new columns will be generated, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required