Spring Deals - hours only!Up to 70% off on all courses and bundles.-Close
Creating data frames
Feature engineering


Perfect! Of course, most of the time you'll create new columns using information from other columns in a data frame. For example, the avg_price column currently represents average housing prices in Euros.

Let's create an additional column called avg_price_usd that will represent average housing prices in dollars. We'll use existing columns to calculate this price: avg_price (which is the average price in Euros), and conversion_rate (which equals 1.20). Here's the expression:

quarter_prices$avg_price_usd <- quarter_prices$avg_price * quarter_prices$conversion_rate

This expression will create a vector with average price converted to USD and it will assign this vector to a new column avg_price_usd in the quarter_prices data frame.

period avg_price conversion_rate avg_price_usd
Q1 2017 170195 1.20 204234
Q2 2017 173937 1.20 208724
Q3 2017 177938 1.20 213526


Chris would like to know the price per square meter for each property that is on sale in Cibaly. The price per square meter for a property can be calculated with the following formula:

 price / living_area

Use the price and living_area columns from the houses data frame to calculate the price per square meter for each property. Store the results in a column named price_per_sq_meter.