Help with Data Clean DATAFRAME

0

I want to create a function that allows me to split a row / column where it has several words, and transport the word I want to another row / column where there is a Nan. as you can see in the example. I would like to be able to take a description of row 3 'Ciudad de mexico' and assign to row 3 that corresponds to the cities column. Make a split with the Key 'Meat' in row 2 of the description column, and if you find it, assign it to row 2 of the culinary column. and so ... I hope the example will be understood below:

import pandas as pd
import numpy as np
Mundo = {
    'ciudades': ['San Jose','buenos aires','NaN'],
    'culinaria': ['pescado','NaN','NaN'],
    'precio': ['Nan','NaN','$20'],
    'descripcion': ['en la ciudad de san jose comemos mucho carne y su precio es 40', 'en la ciudad de buenos aires comemos mucho pescado y su precio es 60','en la ciudad de mexico df comemos muchos tacos y su precio es 20']
}

df = pd.DataFrame(Mundo)
df
    
asked by Emaa 30.08.2018 в 21:42
source

0 answers