import numpy as np
import pandas as pd
rainfall = pd.read_csv('D:\Seattle2014.csv')['PRCP'].values
inches = rainfall / 254
inches.shape
import matplotlib.pyplot as plt
import seaborn;seaborn.set()
plt.hist(inches,40);
x = np.array([1,2,3,4,5])
x < 3
x > 3
x <= 3
x >= 3
x != 3
x == 3
(2 * x) == (x ** 2)
rng = np.random.RandomState(0)
x = rng.randint(10,size=(3,4))
x < 6
np.count_nonzero(x < 6)
np.sum(x < 6)
np.sum(x < 6,axis=1)
np.any(x > 8)
np.any(x < 0)
np.all(x < 10)
np.all( x == 6)
np.all( x < 8, axis=1)
np.sum((inches > 0.5) & (inches < 1))
np.sum(~((inches <= 0.5) | (inches >= 1)))
print("Number days without rain: ", np.sum(inches == 0))
print("Number days with rain: ", np.sum(inches != 0))
print("Days with more than 0.5 inches:", np.sum(inches > 0.5))
print("Rainy days with < 0.1 inches :", np.sum((inches > 0) & (inches < 0.2)))
x
x<5
x [x<5]
rainy = (inches > 0)
summer = (np.arange(365) - 172 < 90) & (np.arange(365) - 172 > 0)
print("Median precip on rainy days in 2014 (inches): ",np.median(inches[rainy]))
print("Median precip on summer days in 2014 (inches): ",np.median(inches[summer]))
print("Maximum precip on summer days in 2014 (inches): ",np.max(inches[summer]))
print("Median precip on non-summer rainy days (inches):",np.median(inches[rainy & ~summer]))
A = np.array([1,0,1,0,1,0],dtype=bool)
B = np.array([1,1,1,0,1,1],dtype=bool)
A | B
x = np.arange(10)
( x > 4 ) & (x < 8)