import pandas as pd
import altair as alt
from vega_datasets import data
= data.cars()
cars cars.head()
Name | Miles_per_Gallon | Cylinders | Displacement | Horsepower | Weight_in_lbs | Acceleration | Year | Origin | |
---|---|---|---|---|---|---|---|---|---|
0 | chevrolet chevelle malibu | 18.0 | 8 | 307.0 | 130.0 | 3504 | 12.0 | 1970-01-01 | USA |
1 | buick skylark 320 | 15.0 | 8 | 350.0 | 165.0 | 3693 | 11.5 | 1970-01-01 | USA |
2 | plymouth satellite | 18.0 | 8 | 318.0 | 150.0 | 3436 | 11.0 | 1970-01-01 | USA |
3 | amc rebel sst | 16.0 | 8 | 304.0 | 150.0 | 3433 | 12.0 | 1970-01-01 | USA |
4 | ford torino | 17.0 | 8 | 302.0 | 140.0 | 3449 | 10.5 | 1970-01-01 | USA |
(cars
.assign(= cars.Miles_per_Gallon * 1.609 / 3.785, # milhas por galão -> km por litro
Miles_per_Gallon = cars.Displacement * 1.609, # milhas -> km
Displacement = cars.Weight_in_lbs * 0.454 # libras -> kg
Weight_in_lbs
)={
.rename(columns'Name':'Nome',
'Miles_per_Gallon':'Quilometros_por_litro',
'Cylinders':'Cilindros',
'Displacement':'Deslocamento_kg',
'Horsepower':'Potencia_cv',
'Weight_in_lbs':'Peso_kg',
'Acceleration':'Aceleracao_s',
'Year':'Ano',
'Origin':'Origem'
}
) )
Nome | Quilometros_por_litro | Cilindros | Deslocamento_kg | Potencia_cv | Peso_kg | Aceleracao_s | Ano | Origem | |
---|---|---|---|---|---|---|---|---|---|
0 | chevrolet chevelle malibu | 7.651783 | 8 | 493.963 | 130.0 | 1590.816 | 12.0 | 1970-01-01 | USA |
1 | buick skylark 320 | 6.376486 | 8 | 563.150 | 165.0 | 1676.622 | 11.5 | 1970-01-01 | USA |
2 | plymouth satellite | 7.651783 | 8 | 511.662 | 150.0 | 1559.944 | 11.0 | 1970-01-01 | USA |
3 | amc rebel sst | 6.801585 | 8 | 489.136 | 150.0 | 1558.582 | 12.0 | 1970-01-01 | USA |
4 | ford torino | 7.226684 | 8 | 485.918 | 140.0 | 1565.846 | 10.5 | 1970-01-01 | USA |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
401 | ford mustang gl | 11.477675 | 4 | 225.260 | 86.0 | 1266.660 | 15.6 | 1982-01-01 | USA |
402 | vw pickup | 18.704359 | 4 | 156.073 | 52.0 | 967.020 | 24.6 | 1982-01-01 | Europe |
403 | dodge rampage | 13.603170 | 4 | 217.215 | 84.0 | 1041.930 | 11.6 | 1982-01-01 | USA |
404 | ford ranger | 11.902774 | 4 | 193.080 | 79.0 | 1191.750 | 18.6 | 1982-01-01 | USA |
405 | chevy s-10 | 13.178071 | 4 | 191.471 | 82.0 | 1234.880 | 19.4 | 1982-01-01 | USA |
406 rows × 9 columns