# Creating New Columns in a DataFrame

There are two primary methods of creating new columns in a DataFrame:

1. Creating a new column calculated from the data you already have (ex: adding a new, calculated value to your DataFrame), or

2. Creating a new column of new data, directly in Python, that is not from another dataset or otherwise already exists.

Note: Creating a new column is different than merging two existing DataFrames together. If you're looking for that, see TODO.

## The Movie Dataset

Throughout this guide, we will use a small DataFrame with data about movies:

## Create a New Column Using a Calculation

We can perform simple mathematical operations on columns and store the resulting numbers in a new column. This includes addition, multiplication, subtraction, and division. We do this so our results are easier to see and available for future analysis.

Let's think about the box office columns in the movie DataFrame. We already have domestic (US) box office and worldwide box office. But what if we wanted to figure out the international box office for each movie? To find this value for each movie, we could subtract domestic from worldwide for every movie by hand — or we could allow Python to do it for us:

Your DataFrame has been permanently modified and will always contain the new columns.

## Create a New Columns With New Data

We can add a new column of data directly with new data organized in a list. One reason we might want to add a column is when we obtain a brand new variable related to the DataFrame. Suppose you wanted to include a new column of your personal rating for each movie:

## Creating a New Column With df.loc

If you have data that exists for only a small number of observations, you can use .loc to modify a DataFrame based on the row index value and the column name. A row index value is the leftmost, bold column in a DataFrame that defaults to a numbered list starting at 0 . When using .loc, choose the row index value(s) that correspond to the rows you have information for.

Continuing our example, say we learned that the critics' rating for "Blade Runner" is an 8.9. Since "Blade Runner" is in the row with index 3, we add its critic rating with the following code: