import pandas as pd
df = pd.read_csv("https://raw.githubusercontent.com/dm-fedorov/pandas_basic/master/data/wine.csv")
df.head()
| 0 |
US |
With a delicate, silky mouthfeel and bright ac... |
NaN |
86 |
€ 23,0 |
California |
Central Coast |
Central Coast |
Pinot Noir |
MacMurray Ranch |
| 1 |
Italy |
D'Alceo is a drop dead gorgeous wine that ooze... |
D'Alceo |
96 |
€ 275,0 |
Tuscany |
Toscana |
NaN |
Red Blend |
Castello dei Rampolla |
| 2 |
France |
The great dominance of Cabernet Sauvignon in t... |
NaN |
91 |
€ 40,0 |
Bordeaux |
Haut-Médoc |
NaN |
Bordeaux-style Red Blend |
Château Bernadotte |
| 3 |
Italy |
The modest cherry, dark berry and black tea no... |
NaN |
81 |
€ 15,0 |
Tuscany |
Chianti Classico |
NaN |
Sangiovese |
Valiano |
| 4 |
US |
Exceedingly light in color, scent and flavor, ... |
NaN |
83 |
€ 25,0 |
Oregon |
Rogue Valley |
Southern Oregon |
Pinot Noir |
Deer Creek |
На основе словаря color ({"variety": "color"}) создайте столбец в таблице df, в котором закодирован цвет вина.
color = {
"Chardonnay": "white",
"Pinot Noir": "red",
"Cabernet Sauvignon": "red",
"Red Blend": "red",
"Bordeaux-style Red Blend": "red",
"Sauvignon Blanc": "white",
"Syrah": "red",
"Riesling": "white",
"Merlot": "red",
"Zinfandel": "red",
"Sangiovese": "red",
"Malbec": "red",
"White Blend": "white",
"Rosé": "other",
"Tempranillo": "red",
"Nebbiolo": "red",
"Portuguese Red": "red",
"Sparkling Blend": "other",
"Shiraz": "red",
"Corvina, Rondinella, Molinara": "red",
"Rhône-style Red Blend": "red",
"Barbera": "red",
"Pinot Gris": "white",
"Viognier": "white",
"Bordeaux-style White Blend": "white",
"Champagne Blend": "other",
"Port": "red",
"Grüner Veltliner": "white",
"Gewürztraminer": "white",
"Portuguese White": "white",
"Petite Sirah": "red",
"Carmenère": "red"
}