Python Basics
print("Hello World")
import pandas as pd
import numpy as np
import seaborn as sns
# Add two nubmber
8 + 5
def add_number(a, b):
return a + b
add_number(10, 70)
Natural Numbers Whole Numbers Integers Rational Numbers Real Numbers Complex Numbers
List
# list = squear brackets
# Address [0, 1, 2, 3.....]
# Address OR [.....-4, -3, -2, -1]
a = [4, 5, 9, 3]
a
a[3]
a[1:3]
a[-2]
Import Data Using Pandas
# head / tail is the top and bottom of the files. Blank brackers show 5,
# adding another number in the () will expand it
nb = pd.read_csv("listings.csv")
nb.head(10)
# to see to top 5 names of the propurties... in this case they are names to help with searches terms
nb['name'].head()
# all colums names
nb.columns
nb['price'].head()
# Opton 1 to only look at two colums use a double braket as if you are creating a new list
nb[['name', 'host_name']]
# option 2
cols = ['name', 'host_name']
nb[cols]
# using a math fuction to find the information you are looking for...
nb['min_rev'] = nb['minimum_nights'] * nb['price']
nb.head()
summary stats.
nb['price'].mean
nb['min_rev'].mean
round(nb['min_rev'].mean(),2)