Create a data frame with several self-defined types in Julia

I have a self-defined mutable struct as the following.

@enum Fruits Apple Pear Orange

I also have a .csv file, of which the second column is called fruitsCategories, which lists the categories of all the fruits. Then, I need to read this csv file. Now, the second column is of type String. But what I need is this self-defined enumerate type Fruits. So how to accomplish this?

Note: I create this .csv file. So I can add one more column, which is called integerCategory. Then combining with the enumerate type, can get the corresponding category.
But is there any other way then? Because the integerCategory is not really necessary…

EDIT: sorry if I did not explain this clearly. When this .csv file is created, I’m using CSV.write(fln, df) to write a data frame df to the file with name fln. So I think it would be great if I somehow can let Julia know that the column fruitsCategories of of a self-defined type, not of type String.

Do you think you might be better off using a CategoricalArray?


Thank you for quick responses. So in stead of enumerate type, a CategoricalArray is better? need to dig more.

I found this link: Is there a way that I can attach string labels to integer values in CategoricalArrays?
Is there anything else that can be done using categoricalarray besides

julia> a = categorical([1,2,1,3])

julia> recode(a, 1=>"a", 2=>"b", 3=>"c")

Thank you.

what is the main difference between enumerate type and categoricalarray in terms of usage then?