def rename_categories old_to_new
      old_categories = categories
      data = to_a.map do |cat|
        old_to_new.include?(cat) ? old_to_new[cat] : cat
      end

      initialize_core_attributes data
      self.categories = (old_categories - old_to_new.keys) | old_to_new.values
      self.base_category = old_to_new[base_category] if
        old_to_new.include? base_category
      self
    end
def rename_categories old_to_new
      old_categories = categories
      data = to_a.map do |cat|
        old_to_new.include?(cat) ? old_to_new[cat] : cat
      end

      initialize_core_attributes data
      self.categories = (old_categories - old_to_new.keys) | old_to_new.values
      self.base_category = old_to_new[base_category] if
        old_to_new.include? base_category
      self
    end
Rename categories.
 @note The order of categories after renaming is preserved but new categories
   are added at the end in the order. Also the base-category is reassigned
   to new value if it is renamed
 @param [Hash] old_to_new a hash mapping categories whose name to be changed
   to their new names
 @example
   dv = Daru::Vector.new [:a, 1, :a, 1, :c], type: :category
   dv.rename_categories :a => :b
   dv
   # => #<Daru::Vector(5)>
   #   0   b
   #   1   1
   #   2   b
   #   3   1
   #   4   c