Skip to content

Instantly share code, notes, and snippets.

View BexTuychiev's full-sized avatar
🏠
Working from home

bexgboost BexTuychiev

🏠
Working from home
View GitHub Profile
films_plus_directors = films.merge(directors, on='director_id', how='inner').drop_duplicates()
# Loading necessary libraries
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# Plotting pretty figures and avoid blurry images
%config InlineBackend.figure_format = 'retina'
# No need to include %matplotlib inline magic command. These things come built-in now.
# Ignore warnings
# Load some sample data
medals = pd.read_csv('data/medals_by_country_2016.csv', index_col=[0])
climate_change = pd.read_csv('data/climate_change.csv', parse_dates=['date'])
# Basic exploration
medals.info()
climate_change.info()
<class 'pandas.core.frame.DataFrame'>
Index: 10 entries, United States to Japan
Data columns (total 3 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Bronze 10 non-null int64
1 Gold 10 non-null int64
# Basic exploration
medals.info()
climate_change.info()
___________________
<class 'pandas.core.frame.DataFrame'>
Index: 10 entries, United States to Japan
Data columns (total 3 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
# Create an arbitrary tuple
numbers = (10, 11, 12)
# Assign each of its values to a single variable
ten, eleven, twelve = numbers
# Two variables because function returns tuple of size 2
fig, ax = plt.subplots()
plt.bar(medals.index, medals['Gold'])
plt.xticks(rotation=90)
plt.ylabel('# of gold medals');
plt.bar(medals.index, medals['Gold'])
plt.xticks(rotation=90)
plt.ylabel('# of gold medals')
plt.plot(climate_change['date'], climate_change['co2']);
_______________
TypeError: tzinfo argument must be
None or of a tzinfo subclass, not type 'UnitData'
fig, ax = plt.subplots()
ax.plot(climate_change['date'], climate_change['co2'])
ax.set(title='Amount of CO2 (ppm) in each year', xlabel='Year',
ylabel='Amount of CO2 (ppm)');