In [1]:
    
import numpy as np
import pandas as pd
    
In [4]:
    
x = pd.Series([1, 2, 3, 4, 5])
x
    
    Out[4]:
In [5]:
    
x+100
    
    Out[5]:
In [8]:
    
(x ** 2) * 100
    
    Out[8]:
In [7]:
    
x > 2
    
    Out[7]:
In [9]:
    
larger_than_2 = x > 2
    
In [10]:
    
larger_than_2.any()
    
    Out[10]:
In [12]:
    
larger_than_2.all()
    
    Out[12]:
In [13]:
    
larger_than_2.argmax()
    
    Out[13]:
In [21]:
    
def f(x): 
    if x % 2 == 0:
        return x * 2
    else:
        return x * 3
x.apply(f)
    
    Out[21]:
In [23]:
    
%%timeit
ds = pd.Series(range(1000))
for counter in range(len(ds)):
    ds[counter] = f(ds[counter])
    
    
In [24]:
    
%%timeit
ds = pd.Series(range(1000))
ds = ds.apply(f)
    
    
these objects are refrence objects, so you have to do y = x.copy() to not overite x when changing a value in y
In [30]:
    
x.describe()
    
    Out[30]:
In [39]:
    
y = pd.Series(np.random.random(100) * 1000)
y.describe()
    
    Out[39]:
In [99]:
    
import matplotlib.pyplot as plt
    
In [74]:
    
new = np.reshape(np.array(y.tolist()), (10,10))
plt.imshow(new)
plt.colorbar()
plt.show()
    
    
In [81]:
    
data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
df = pd.DataFrame(data, columns=["x"])
    
In [76]:
    
df
    
    Out[76]:
In [82]:
    
df['x squared'] = df['x'] ** 2
    
In [83]:
    
df
    
    Out[83]:
In [84]:
    
df['is even'] = df['x'] % 2 == 0
    
In [85]:
    
df['ood even'] = df['is even'].map({False:"odd", True:"even"})
    
In [86]:
    
df
    
    Out[86]:
In [88]:
    
cf = df.drop("is even", 1)
    
In [89]:
    
cf
    
    Out[89]:
In [90]:
    
df
    
    Out[90]:
In [91]:
    
df[['x', 'is even']]
    
    Out[91]:
In [92]:
    
df[df['is even'] == False]
    
    Out[92]:
In [94]:
    
df[(df['is even'] == False) | (df['x squared'] > 25)]
    
    Out[94]:
In [95]:
    
df[(df['is even'] == False) & (df['x squared'] > 25)]
    
    Out[95]:
In [101]:
    
df.describe()
    
    Out[101]:
In [ ]: