Replace a specific text value in a table with NaN

20 visualizaciones (últimos 30 días)
Gabi el 16 de Jun. de 2022
Comentada: Image Analyst el 27 de Jun. de 2022
I've got a table generated from importing *.csv data.
Some of the values in the table read as 'NOVALUE' and I would like to replace them all by NaN. The table can have various sizes (both in number of columns and rows), so the rule will have to apply to the entire table wherever a 'NOVALUE' is found.
I've tried a few examples with table2array and == but none seems to work in this specific case.
  4 comentarios
Image Analyst
Image Analyst el 27 de Jun. de 2022
Would the whole column be NOVALUE like you showed, or might some of the other elements have a value.
Would you rather just delete the entire column?
Can you attach one of your CSV files with the paperclip icon after you read this:

Iniciar sesión para comentar.

Respuestas (1)

Chandrika el 27 de Jun. de 2022
As per my understanding, you want to standardize the missing values in the table. We can do this using 'TreatAsMissing'. You can try using the following code for the same:
data= readtable("Filename.csv","TreatAsMissing","NOVALUE");
Here, 'Filename.csv' refers to the .csv file. As output, all table elements corresponding to "NOVALUE" would get set to NaN.
Hope this helps!





Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by