# (Python Example for Citizen Data Scientist & Business Analyst)

Write a Python program to perform Counter arithmetic and set operations for aggregating results.

Sample Solution:

Python Code:

``````
import collections

c1 = collections.Counter([1, 2, 3, 4, 5])
c2 = collections.Counter([4, 5, 6, 7, 8])

print('C1:', c1)
print('C2:', c2)
print('nCombined counts:')
print(c1 + c2)
print('nSubtraction:')
print(c1 - c2)
print('nIntersection (taking positive minimums):')
print(c1 & c2)
print('nUnion (taking maximums):')
print(c1 | c2)
``````

Sample Output:

```C1: Counter({1: 1, 2: 1, 3: 1, 4: 1, 5: 1})
C2: Counter({4: 1, 5: 1, 6: 1, 7: 1, 8: 1})

Combined counts:
Counter({4: 2, 5: 2, 1: 1, 2: 1, 3: 1, 6: 1, 7: 1, 8: 1})

Subtraction:
Counter({1: 1, 2: 1, 3: 1})

Intersection (taking positive minimums):
Counter({4: 1, 5: 1})

Union (taking maximums):
Counter({1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1})```

# Special 95% discount

## 2000+ Applied Machine Learning & Data Science Recipes

### Portfolio Projects for Aspiring Data Scientists: Tabular Text & Image Data Analytics as well as Time Series Forecasting in Python & R

```
Disclaimer: The information and code presented within this recipe/tutorial is only for educational and coaching purposes for beginners and developers. Anyone can practice and apply the recipe/tutorial presented here, but the reader is taking full responsibility for his/her actions. The author (content curator) of this recipe (code / program) has made every effort to ensure the accuracy of the information was correct at time of publication. The author (content curator) does not assume and hereby disclaims any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from accident, negligence, or any other cause. The information presented here could also be found in public knowledge domains.```