Python

  • Python Notes: Pandas from getting started Tutorials
    Notes from Getting Started Tutorial:https://pandas.pydata.org/docs/getting_started/intro_tutorials/03_subset_data.html 1. Creating a Dataframe and Series 2. Create Plots with Matplotlib 3. Add new columns from existing columns 4. Summary Statistics 5. Re-shape layout of tables 6. Sub-sets and Filtering import pandas as pd#read csv file to pandas DatafFrametitanic = pd.read_csv(“titanic.csv”)air_quality = pd.read_csv(“air_quality_no2.csv”, index_col=0, parse_dates=True) #save as excel, index=False removes… Read more: Python Notes: Pandas from getting started Tutorials
  • Python Notes: Python Lists Examples
    Create a listSimple listmylist = [“apple”, “orange”, “banana”, “mango”, “pineapple”]mylist[2] # returns ‘banana’mylist[-1] # returns ‘pineapple’mylist[2:4] #returns ‘banana’, ‘mango’, ‘pineappleif “apple” in thislist:  print(“Yes, ‘apple’ is in the fruits list”)mylist.insert(2, “watermelon”) #insert at position speifiedmylist.append(‘grapes’) #adds to end of listmylist = [“apple”, “banana”, “cherry”]tropical = [“mango”, “pineapple”, “papaya”]mylist.extend(tropical) # adds tropical list to thislistmy.remove(“banana”) #removes first occurrencemylist.pop(1) #removes specified instancedel mylist[0] #also removes instancedel mylist… Read more: Python Notes: Python Lists Examples
  • Simple Linear Regression Example with Python
    Linear Regression using Salary and Years of Experience Data Data Source: Salary_dataset.csv KaggleThe salary data set includes 2 columns: Years Experience which will be our independent variable (X) and Salary (Y). Linear regression is a fundamental statistical method used to model the relationship between a dependent variable and one or more independent variables. The primary… Read more: Simple Linear Regression Example with Python
  • Python Notes: Pandas Code Examples
    Pandas Quick Guide Modules import pandas as pd #pandas moduleimport scipy.stats as stats #stats sub-modulefrom bs4 import BeautifulSoup #scrape moduleimport requests #API moduleimport whois as whois #whois module Filesdf = pd.read_csv(“CookieData.csv”) #import CSV file to dataframe df #define index column and convert dates to date format air_quality = pd.read_csv(“air_quality_long.csv”, index_col=”date.utc”, parse_dates=True) air_quality.to_csv(“checkcombine.csv”) #save dataframe to… Read more: Python Notes: Pandas Code Examples
  • An Example of Poor Correlation using Python
    In order to find the best data build our model, we need to run correlations on the data. In the initial predictive model we built, we guessed the fields, namely age, gender, income and first purchase amount, but the model gave a very poor MSE accuracy result, so we need to go back to the… Read more: An Example of Poor Correlation using Python