Python Pandas For Your Grandpa - 5.4 Challenge: Family IQ

Setup Define a person’s Family IQ Score as Family IQ Score = 0.5 * IQ score + 0.5 * relatives’ IQ score where relatives’ IQ score is the average IQ score of that person’s parents, full siblings, and children. Given a dataset of people and their IQ scores, determine who has the highest Family IQ score. import numpy as np import pandas as pd generator = np.random.default_rng(2718) persons = pd.

Python Pandas For Your Grandpa - 5.5 Challenge: Concerts

Setup Given a dataset of concerts, count the number of concerts per (artist, venue) pair, per year-month. Make the resulting table be a wide table - one row per year-month with a column for each unique (artist, venue) pair. Use the cross product of the artists and venues Series to determine which (artist, venue) pairs to include in the result. import numpy as np import pandas as pd pd.set_option('display.max_columns', 500) pd.

Python NumPy For Your Grandma - 1.1 Introduction

Introduction Hey, thanks for checking out my course - Python NumPy for your Grandma, so easy your grandma could learn it! In this course, we’re gonna cover everything you’d wanna know about NumPy, including array creation, broadcasting, indexing, random number generation, and a whole lot more. And we’re gonna do it through a combination of theory, examples, and practice problems. Things To Know. I’m using NumPy version 1.19.3 If you’re using a later version, it probably doesn’t matter.

Python NumPy For Your Grandma - 2.1 NumPy Array Motivation

The primary data structure in NumPy is the N-dimensional array, so that’s gonna be the focus of this course. But before we start using arrays, let’s motivate their existence. Suppose you have a lot of data, like the price of a stock measured every second for a year. That’s about 32 million values. To represent this data in native Python, the most obvious data structure we could use is a list.

Python NumPy For Your Grandma - 2.2 NumPy Array Basics

Before we can start using numpy, we need to install it and import it. The easiest way to install it is with pip. So, pip install numpy. If you’re using google colab like me, you can do !pip install numpy, but you don’t even need to do that because it’s already installed by default. And then conventional way to import numpy is like this. import numpy as np We’ll start by making our first array from a list of numbers.

Python NumPy For Your Grandma - 2.3 Creating NumPy Arrays

In this secion, we’ll look at different ways to create a NumPy array. As we saw earlier, you can make an array by typing np dot array and then passing in a list of values. import numpy as np np.array(['a', 'b', 'c']) ## array(['a', 'b', 'c'], dtype='<U1') You can also make a 2-dimensional array from a list of lists like this. np.array([ ['a', 'b'], ['c', 'd'], ['e', 'f'] ]) ## array([['a', 'b'], ## ['c', 'd'], ## ['e', 'f']], dtype='<U1') You can also make a three dimensional array from a list of lists of lists.