"No one is harder on a talented person than the person themselves" - Linda Wilkinson ; "Trust your guts and don't follow the herd" ; "Validate direction not destination" ;

October 04, 2016

Day #33 - Pandas Deep Dive

import pandas as pd
#Create Data Frame with few columns and list values
df = pd.DataFrame({'A':[1,2,3,4],'B':[5,6,7,8]})
print(df)
#Drop a Column
df = df.drop('A',1)
print(df)
#Create column with int column names
df = pd.DataFrame({1:[1,2,3,4],2:[1,2,3,4],10:[1,2,3,4]})
print(df)
df = df.drop(1,1)
print(df)
#Sample two rows from data frame
print(df.sample(n=2))
#Create list with 56 values
a = []
for i in range(1,56):
a.append(i)
import random
#Sample 15 random entries
feature2 = random.sample(a,15)
print('feature')
print(df)
#Find maximum occuring values row wise
print(df.mode(axis=1))
Happy Learning!!!

No comments: