-1

I am working with a dataframe with multiple columns and rows. I am trying to get rid of the cells within that frame that have null values.

I have read about dropna(), but dropna() will drop the entire row or column. What if I still want to keep the row and column, but just get rid of the specific cell without the info.

My DF looks something like this :

    id  typology    area    floor   price   seller contact  link    title   region_parish
0   31508143    T1  82  3º andar    330000  9.25105e+08 https://www.idealista.pt/imovel//   Apartamento T1 na rua Manuel da Fonseca, 4, La...   benfica
1   31509096    T3  130 NaN 450000  2.15553e+08 https://www.idealista.pt/imovel//   Apartamento T3 em Laranjeiras, São Domingos de...   benfica
2   31509028    T3  128 NaN 485000  2.1556e+08  https://www.idealista.pt/imovel//   Apartamento T3 na rua Mateus Vicente, s/n, Alt...   benfica
3   31508706    T3  112     425000  2.15553e+08 https://www.idealista.pt/imovel//   Apartamento T3 na rua Manuel Ferreira de Andra...   benfica
4   31508608    T3  146 7º andar    645000  2.15554e+08 https://www.idealista.pt/imovel//   Apartamento T3 na rua Manuel da Fonseca, 2, La...   benfica
... ... ... ... ... ... ... ... ... ...
527 29460136    T2  30  NaN 170000  2.15567e+08 https://www.idealista.pt/imovel//   Moradia em Centro - Nova Campolide, Campolide   campolide
528 29386567    T2  115 Rés do chão 215000  2.15551e+08 https://www.idealista.pt/imovel//   Apartamento T2 em Centro - Nova Campolide, Cam...   campolide
529 29054084    T4  122 NaN 449000  2.15553e+08 https://www.idealista.pt/imovel//   Apartamento T4 na rua Artilharia 1, s/n, Centr...   campolide
530 28395729    T3  150 NaN 750000  2.15553e+08 https://www.idealista.pt/imovel//   Apartamento T3, Vila Ferro, Bairro da Serafina...   campolide
531 27566733    T3  80  2º andar    300000  9.62397e+08 https://www.idealista.pt/imovel//   Apartamento T3 na rua general taborda, 82, Cen...   campolide
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
izzypt
  • 170
  • 2
  • 16
  • What do you mean by getting rid of a specific cell? Can you give an example of the result? – Daniel Geffen Nov 26 '21 at 12:30
  • Hi, for example, in floor, or contact seller where the value is Nan, keep the row and the column but drop the value. If that's not possible, at least change the value to an empty string. The ultimate goal will be to convert that entire column with astype(), but I can't do it If I have nulls ! – izzypt Nov 26 '21 at 12:36

1 Answers1

1

I assume you mean show anything other than NaN like "" blank. You can do that using fillna().

But, I would suggest writing a sample of the data into your target first. Most often it will show up as NULL in Databases and blank in CSV or xlsx files. Decide how you want it to be after that.