BaşlayınÜcretsiz Başlayın

Uniform currencies

In this exercise and throughout this chapter, you will be working with a retail banking dataset stored in the banking DataFrame. The dataset contains data on the amount of money stored in accounts (acct_amount), their currency (acct_cur), amount invested (inv_amount), account opening date (account_opened), and last transaction date (last_transaction) that were consolidated from American and European branches.

You are tasked with understanding the average account size and how investments vary by the size of account, however in order to produce this analysis accurately, you first need to unify the currency amount into dollars. The pandas package has been imported as pd, and the banking DataFrame is in your environment.

Bu egzersiz

Cleaning Data in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Find the rows of acct_cur in banking that are equal to 'euro' and store them in the variable acct_eu.
  • Find all the rows of acct_amount in banking that fit the acct_eu condition, and convert them to USD by multiplying them with 1.1.
  • Find all the rows of acct_cur in banking that fit the acct_eu condition, set them to 'dollar'.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Find values of acct_cur that are equal to 'euro'
acct_eu = banking['____'] == '____'

# Convert acct_amount where it is in euro to dollars
banking.loc[____, '____'] = banking.loc[____, '____'] * ____

# Unify acct_cur column by changing 'euro' values to 'dollar'
banking.loc[____, '____'] = ____

# Assert that only dollar currency remains
assert banking['acct_cur'].unique() == 'dollar'
Kodu Düzenle ve Çalıştır