2021年4月27日星期二

Please help me out this permutation and combination

Data:

        Items Category  Value          apple   Fruits      2         banana   Fruits      2         grapes   Fruits      4           Abhi    Names      5          Ayush    Names      4          Krish    Names      3         Kartik    Names      4          Paras    Names      3         School    Place      5     Playground    Place      4      Courtyard    Place      1           Farm    Place      4          Shirt  Clothes      6           Pant  Clothes      4          Jeans  Clothes      1          Socks  Clothes      2          Shoes  Clothes      1   Handkerchief  Clothes      1         Jacket  Clothes      3        T-Shirt  Clothes      4  
import pandas as pd  from itertools import permutations, combinations    Grouped = data.groupby(["Category"])  Fruits = Grouped.get_group('Fruits')  Names = Grouped.get_group('Names')  Place = Grouped.get_group('Place')  Clothes = Grouped.get_group('Clothes')    all = combinations([Fruits, Names, Place, Clothes], 6)    for i in all:      print (i)  

Note: I want only 6 items from the combination of all (Fruits,Names, Place and Clothes) and the total value of 6 items not exceeding 15. The combination must contain below: Fruits= minimum 1 and maximum 3 Names= minimum 2 and maximum 3 Place= Minimum 1 and maximum 2 Clothes= minimum 2 and maximum 4

https://stackoverflow.com/questions/67293929/please-help-me-out-this-permutation-and-combination April 28, 2021 at 12:48PM

没有评论:

发表评论