Chocolate percentages
You would like to bite into the chocolates DataFrame to get analyzing. However, the chocolate percentage is given as a string with the percentage sign. That won't do! It's time to use your new column and row skills to fix that.
chocolates contains, among others, the following columns important for this exercise:
cocoa_percentage, containing the cocoa percentage as a string, e.g.,"65.5%";location, containing the country where the chocolate was manufactured;bean_location, containing the country where the chocolate bean was grown;rating, containing the average customer rating of the chocolate.
DataFrames package has been loaded for you with the using keyword
Este ejercicio forma parte del curso
Data Manipulation in Julia
Instrucciones del ejercicio
- Create a new column,
cocoa, by removing the percentage sign fromcocoa_percentageand casting the result as aFloat64. - Drop the
cocoa_percentagecolumn. - Reorder the columns so that the order is
cocoa,rating,location,bean_locationand rewrite the original DataFrame.
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
# Create a new column for cocoa percentage
____!(chocolates, ____ => ____ => ____)
# Drop the cocoa_percentage column
____!(chocolates, ____)
# Reorder columns
____!(chocolates, ____)
println(first(chocolates, 5))