Trade Balance Ratio

Now, let's examine the two columns, share_country_maritime_export and share_country_maritime_import. We want you to calculate a trade balance ratio using these two columns and store the result in a new column named trade_balance_ratio.

First, you should check if both share_country_maritime_export and share_country_maritime_import are numerical data types. If not, it's essential to convert them to a numerical type before performing the calculation.

You can use the .dtypes attribute to check the data type of each column.

Make sure to change the decimal separator if needed before converting to a numerical type.

Also, ensure you remove any percentage signs before converting to a numerical type.

Use the Pandas library to convert the columns from an 'object' data type to a numerical data type.

Before you start dividing the share_country_maritime_export column by the share_country_maritime_importcolumn to create a new column called trade_balance_ratio, make sure that there are no rows where the share_country_maritime_import is equal to zero (as you can't divide by 0). You can change those 0 values to 0.01 for the subsequent analysis.

Last updated