Search code examples
pythonpandaspoker

Python Multiindexing and custom sorting


I have a pandas series (edit: whoops meant dataframe) as shown here: image

I have two questions. First, what is the syntax to display/return all winning hands where Players at Table = 4, and Players to Showdown = 2?

Secondly, I am trying to then sort the "winning hand" values in order of their poker strength. Would I have to create a custom sort algorithm for this, where I would pre-code information such as King pair > Jack pair? I'm not really sure what the most efficient way to go about this is.


Solution

  • That is a DataFrame, not a Series. Try

    df.loc[4, 2]
    

    Your second question is more complicated, and might warrant its own SO question. Please post code instead of images!