modify records without altering the entire column #6815
-
Hi, my sample case: (
t
.mutate(iso2c = ibis.where(_.country_name_given=="St.Kitts&Nevis", "KN", _.iso2c))
.mutate(country = ibis.where(_.country_name_given=="St.Kitts&Nevis", "St. Kitts and Nevis", _.country))
.mutate(cluster = ibis.where(_.country_name_given=="St.Kitts&Nevis", "NAM", _.cluster))
) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
@ozgurkalan Thanks for opening the discussion! Are you asking for something with more concise syntax than what you're showing here? |
Beta Was this translation helpful? Give feedback.
-
@ozgurkalan How about this version with the REPLACEMENTS = {"iso2c": "KN", "country": "St. Kitts and Nevis", "cluster": "NAM"}
t.mutate(
s.across(
REPLACEMENTS,
lambda c: ibis.where(
t.country_name_given == "St.Kitts&Nevis", REPLACEMENTS[c.get_name()], c
),
)
) |
Beta Was this translation helpful? Give feedback.
@ozgurkalan How about this version with the
across
selector?