Untitled

mail@pastecode.io avatar
unknown
plain_text
23 days ago
771 B
2
Indexable
Never
def fun(df):
  data = {}
  for index, row in df.iterrows():
    data[row['date_added']] = data.get(row['date_added'], {})
    sizes = row['sizes'].split('/')
    int_sizes = [int(size) for size in sizes]

    for size in int_sizes:
      val = data[row['date_added']].get(size, 0)
      if row['type'] == 'Received':
        print(size)
        print(val)
        print('--')
        data[row['date_added']][size] = val + 1
      else:
        data[row['date_added']][size] = val - 1

  for outer_key, inner_dict in data.items():
    print(f"Base key: {outer_key}")
    for inner_key, inner_value in inner_dict.items():
        print(f"  Inner key: {inner_key}, Inner value: {inner_value}")
        if inner_value < 0:
          return "Not Possible"

  return "Possible"
Leave a Comment