I write about Python and AWS for beginner. I'd be delighted any comment.

I’ve tried to deploy AWS Lambda functions of Python (including external library such as numpy, pandas etc.) using CodeCommit, CodeBuild, and CloudFormation and orchestrated by CodePipeline.

This makes it very easy to deploy Lambda functions but a bit hard to set up for me, so I’m going to write down.

Image for post
Image for post

Proceed with the following steps:
1. Create a repository on CodeCommit
2. CLONE repository and PUSH source code, build template, and deploy template files to the repository
3. Create a S3 bucket and CloudFormation role before create a pipeline
4. Create pipeline in CodePipeline (also create)
5. …


I defined CI/CD pipeline to deploy Lambda functions before. Please see my article to get details.

It was technically, just automated delivery process, but if you’re DevOps engineer you have to define continuous integration, automation testing in particular.

Today, I’d like to write about how to define automation testing in AWS CodeBuild.

Image for post
Image for post

Our goals are:

  • Test Lambda function in CodeBuild with SAM CLI
  • If error occurs, stop deployment

I’m going to proceed on the premise that you’ve already defined deploy pipeline, so please also see my article about pipeline before hands-on.

Define buildspec.yml

First, you change commands in buildspec.yml …


“Practical Object-Oriented Design”, written by Sandi Metz, is a masterpiece that written about timeless and fundamental OOD knowledge. To deepen my understanding, I summarize each chapter and rewrite the sample code in Python. Of course, if you’d like to get more details, please get this book.

This article is a summary of chapter 3, “Managing Dependencies”.

Image for post
Image for post

Understanding Dependencies

When an object depends on another object, if one object changes, the other might be forced to change.

Sample code follows:

class Gear:
def __init__(self, chainring, cog, rim, tire):
self.chainring = chainring
self.cog = cog
self.rim = rim
self.tire = tire
def ratio(self):
return self.chainring / float(self.cog) …


“Practical Object-Oriented Design”, written by Sandi Metz, is a masterpiece that written about timeless and fundamental OOD knowledge. To deepen my understanding, I summarize each chapter and rewrite sample code in Python. Of course, if you’d like to get more details, please get this book.

This article is summary of chapter 2, “Designing Classes with a Single Responsibility”.

Image for post
Image for post

Deciding What Belongs in a Class

This chapter focus on how to decide what belongs in class.

Firstly, we need to group methods into class. However, we cannot do this correctly at early stage of project because our applications need to be changed in the future.

Therefore, we have to organize code to be easy to change. To achieve this, the code should follow TRUE…


I’ve worked with SQL for several years before I started using Pandas in Python. I eventually got used to it but I struggled with the syntax differences between them when I started.

As you learn pandas, you eventually wonder how you can implement join in pandas like in SQL. I’m going to write down about it in this article.

Before starting, I gathered basic syntax and comparison in this article. Please see also:

Image for post
Image for post

Dataset

import pandas as pddf_team = [
[1, "Arizona Diamondbacks"]
, [2, "Colorado Rockies"]
, [3, "Los Angeles Dodgers"]
, [4, "San Diego Padres"]
, [5, "San Francisco Giants"]
]
team_columns = ["Id", "Name"]
teams = pd.DataFrame(data=df_team, …


I’ve worked with SQL for several years before I started using Pandas in Python. I eventually get used to it but I struggled syntax difference between them when I started.

I want to gather syntax comparison in this article, also as cheat sheet. I’m going to mention to the basic syntax but if there is another example that doesn’t exist in this article, please let me know!

Image for post
Image for post

Dataset

I’m going to use this dataset.

import pandas as pddf_list = [
["Lamar Jackson", 23, "Ravens", "QB"]
, ["Russell Wilson", 31, "Seahawks", "QB"]
, ["Aaron Donald", 29, "Rams", "DT"]
, ["Patrick Mahomes", 24, "Chiefs", "QB"]
, ["Michael Thomas", 27, "Saints", "WR"]
, ["Christian McCaffrey", 24, "Panthers", "RB"]
, ["George Kittle", 26, "49ers", "TE"]
, ["DeAndre Hopkins", 28, "Cardinals", "WR"]
, ["Stephon Gilmore", 29, "Patriots", "CB"]
, ["Derrick Henry", 26, "Titans", "RB"]
]
df_columns = ["Name", "Age", "Team", "Position"]
players = pd.DataFrame(data=df_list, …


NFL 2020 season is coming soon. For preview this season, I’m going to visualize some quarterbacks data using 2019 dataset.

1. Overview

In this article, I’m going to use this dataset as below. Thanks to Mr. Ron Yurko.

There is play-by-play dataset of pre-season, regular season and play-off. I’m going to use only regular season and visualize every team defensive stats, especially pass defense and run defense. This is brief visualization so please note that not kind of analysis and deeping dive.

Let’s get down to implementation.

About offense, I did about quarterback and rusher with individual stats. …


NFL 2020 season is coming soon. For preview this season, I’m going to visualize some rushing data using 2019 dataset.

Please see also my article about quaterback data visualization.

1. Overview

In this article, I’m going to use this dataset as below. Thanks to Mr. Ron Yurko.

There is play-by-play dataset of pre-season, regular season and play-off. I’m going to use only regular season and visualize some rusher stats. How many run yards did they have in total and on average? How is their performance when in the specific situation such as quarter, down and score behind.

OK, Let’s get down to implementation. …


NFL 2020 season is coming soon. For preview this season, I’m going to visualize some quarterbacks data using 2019 dataset.

1. Overview

In this article, I’m going to use this dataset as below. Thanks to Mr. Ron Yurko.

There is play-by-play dataset of pre-season, regular season and play-off. I’m going to use only regular season and visualize some quarterback stats. What kind of type? Pocket passer or Mobile QB? How is their performance? How is it when they are in the specific situation such as quarter, down and score behind?

OK, Let’s get down to implementation.

2. Preprocessing

import pandas as pd
pd.set_option(“max_columns”, 400)
pbp = pd.read_csv(“play_by_play_data/regular_season/reg_pbp_2019.csv”)
roster = pd.read_csv(“roster_data/regular_season/reg_roster_2019.csv”) …


Overview

Using open source data from Wyscout, I extracted data and format into csv. To get more details, please see my article below:

Now we have prepared play by play data so I’m going to visualize football data with Python. This time, I visualize average passing position, direction and distance, this is called “Pass Sonar”.

I use Google colab so don’t need to build any environment on your laptop.

1. Read csv and look into data

Firstly, read the csv files.

import pandas as pd
pd.set_option(“max_columns”, 100)
matches = pd.read_csv(“csv/matches.csv”)
matches_member = pd.read_csv(“csv/matches_member.csv”)
events = pd.read_csv(“csv/events.csv”)
event_kinds = pd.read_csv(“csv/eventKinds.csv”)
sub_event_kinds = pd.read_csv(“csv/subEventKinds.csv”)
players = pd.read_csv(“csv/players.csv”)
teams = pd.read_csv(“sv/teams.csv”)

I want visualize Spain v. …

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store