0

I was wondering what the difference is between the Symbol type and Sym type in dataframe in Julia. Here is an example with Symbol which is defined with ::

julia> using DataFrames

julia> df = DataFrame(V1 = [:True, :False])
2×1 DataFrame
 Row │ V1     
     │ Symbol 
─────┼────────
   1 │ True
   2 │ False

As you can see the type is now a Symbol. If we define it just like True/False the type will be Sym like this:

julia> df = DataFrame(V1 = [True, False])
2×1 DataFrame
 Row │ V1    
     │ Sym   
─────┼───────
   1 │  True
   2 │ False

As you can see the type is now Sym. Here using typeof for both True:

julia> typeof(:True)
Symbol

julia> typeof(True)
Sym

I know we have this beautiful answer: What is a "symbol" in Julia?, but I can't find anything about Sym. So I was wondering what is the difference between Symbol and Sym in a dataframe of Julia?


Version of DataFrames:

julia> Pkg.status("DataFrames")
Status `~/.julia/environments/v1.8/Project.toml`
  [a93c6f00] DataFrames v1.4.4
Quinten
  • 35,235
  • 5
  • 20
  • 53

1 Answers1

0

When removing the SymPy package with Pkg.rm("SymPy"), the sym type is gone:

julia> df = DataFrame(V1 = [True, False])
ERROR: UndefVarError: True not defined
Stacktrace:
 [1] top-level scope
   @ REPL[5]:1
Quinten
  • 35,235
  • 5
  • 20
  • 53
  • `Sym` is a type defined in `SymPy` and the type of `True` and `False`. Whereas `:True` and `:False` are using `Julia's` notation to create a symbol (the colon). Symbols have type `Symbol`. In each case, `DataFrames` just prints the type of the vector for the column. – jverzani Jan 04 '23 at 20:29