Here is a small example:
mutable struct Mystring str::String end using DataFrames strs = ["a","b","a","b"]; mystrs = Mystring.(strs); df = DataFrame(col_str=strs, col_mystr=mystrs); println(df) println(groupby(df, :col_str)) println(groupby(df, :col_mystr))
I would expect both
groupby()'s to return the same groups (g1 gets rows 1 and 3, and g2 gets rows 2 and 4). Instead, the
groupby(df, :col_mystr) returns 4 groups, each having a single row.
I tried overloading the simple comparison operators, but the result did not change:
Base.:(==)(str1::Mystring, str2::Mystring) = str1.str == str2.str Base.:(>)(str1::Mystring, str2::Mystring) = str1.str > str2.str Base.:(<)(str1::Mystring, str2::Mystring) = str1.str < str2.str
Important is also that this behavior is specific to mutable struct; if
Mystring is declared as an immutable
What am I missing?