Knowledge Base

Reshaping Data

Arithmetic operations

In pandas, you can perform arithmetic operations on columns: addition, subtraction, multiplication, and division. For example:

1data['column1'] = data['column2'] + data['column3']
2data['column1'] = data['column2'] - data['column3']
3data['column1'] = data['column2'] * data['column3']
4data['column1'] = data['column2'] / data['column3']

Selective Value Change

If a condition is not satisfied by the first parameter, then the value is replaced by the second parameter

1data['column'].where(s > control_value, default_value)

Renaming Columns

One part of this process is naming columns. This is what the rename() method is for.

Send Feedback
close
  • Bug
  • Improvement
  • Feature
Send Feedback
,