-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboolean.py
More file actions
39 lines (27 loc) · 973 Bytes
/
Copy pathboolean.py
File metadata and controls
39 lines (27 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# boolean reduction
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
# creating random data
random_data = np.random.randint(1, 101, size=(4, 3))
df = pd.DataFrame(random_data, columns=['A', 'B', 'C'])
print("--- Randomly Generated Table ---")
print(df)
threshold = 50
print(f"\nGoal: Find numbers greater than {threshold}")
test = df > threshold
print("\n--- The 'Reduced' Results ---")
# .any()
print("Does each column have AT LEAST ONE success?")
print(test.any())
# .all()
print("\nIs EVERY number in a row a success?")
print(test.all(axis=1)) # the axis could be changed
# additional
print("\n--- Data Health Check ---")
print(f"Is the table empty? {df.empty}")
print(f"Are all values in Column A unique? {df['A'].is_unique}")
print(f"Are there any missing values (NaNs)? {df.isnull().values.any()}")
# example of this is given in the coin_flip.py file
# the commit is not working on the github is somethig wrong
# it started working