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, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access