Other articles


  1. Dataframe manipulation sequence - GroupBy Agg, Melt, Unstack

    Problem

    From a Pandas DataFrame, massage the DataFrame into a format where order Count and Total Amount could be determined for each Vendor and each Vendor-Buyer combination.

    :::python

    >> df = pd.DataFrame(data=
        {'Vendor': ['A', 'A', 'A', 'B', 'B', 'C', 'C', 'C', 'C',
                'D', 'D', 'E', 'E', 'E', 'E', 'E'],      
        'Buyer …
    read more
  2. MultiIndex.to_frame()

    Problem

    From a MultiIndex dataframe, determine the total number of elements in the Buyer column for each Vendor.

    What I did

    Let's say we have the following DataFrame:

    :::python

    >> df = pd.DataFrame(data=
        {'Vendor': ['A', 'A', 'B', 'C', 'C', 'C',
                'D', 'D', 'E', 'E', 'F', 'G', 'G'],      
        'Buyer':['BU1', 'BU3 …
    read more
  3. MultiIndex.set_levels() in pandas

    Problem

    A user filed an issue on the pandas repo regarding MultiIndex.set_levels - and it turns out the user had some confusion between the set_levels method and the set_names method for MultiIndex due to the documentation. Hence, the MultiIndex.set_levels documentation was marked by the maintainers for improvements to clarify …

    read more

links

social