Python Basics
#importing packages
import pandas as pd
import numpy as np
import seaborn as sns
print("Hello World")
#adding two numners
2 + 5
#defining a function
def add_number(a, b):
return a + b;
#calling function
add_number(10, 20)
a = [4, 5, 9, 3]
a
a[2]
a[1:3]
nb = pd.read_csv("listings.csv")
nb.head()
nb.tail()
nb['name'].head()
nb.columns
cols = ['name', 'host_name']
nb[cols]
#calculate using two columns;
#a new column will be created and appended at the end of the columns(last column)
nb['min_rev'] = nb['minimum_nights'] * nb['price']
# just to see if column is added at the end of the dataframe(table)
nb.head()
round(nb['min_rev'].mean(), 2)