Skip to content

Instantly share code, notes, and snippets.

@monocongo
Created June 22, 2022 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monocongo/853f49fec2705ab12cd94bfd20b38cf7 to your computer and use it in GitHub Desktop.
Save monocongo/853f49fec2705ab12cd94bfd20b38cf7 to your computer and use it in GitHub Desktop.
Below we demonstrate how to utilize [sbpy](https://sbpy.readthedocs.io/en/latest/index.html) to transform an unpacked designation to packed format
import pandas as pd
from sbpy.data import Names
# function to create the new packed format column
def pack_designation(
row: pd.Series,
) -> pd.Series:
return pd.Series(
data=[Names.to_packed(row.pdes)],
index=['Principal_desig'],
)
...
# crete a new column containing the designation in packed format
df = df.join(leaderboard_df.apply(pack_designation, axis=1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment