This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
void change_val(int &z); | |
int main() { | |
int a = 1; | |
int *b = &a; | |
cout << "b points to an alias of the integer a\n"; | |
cout << "a=" << a << ", b=" << b << ", *b=" << *b << endl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() { | |
int a = 1; | |
int b = a; | |
cout << "b gets the value that is inside a\n"; | |
cout << "a=" << a << ", b=" << b << endl; | |
// prints: a=1, b=1 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Hello World | |
/* By Dalya G */ | |
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
cout << "Hello World" << endl; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ax = df_grouped_color.plot.bar(stacked=True, color=['brown', 'black']) | |
ax.set_xticklabels(labels=df_grouped_color.index, rotation=70, rotation_mode="anchor", ha="right") | |
ax.set_xlabel('') | |
ax.set_ylabel('n_pets'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df['has_black'] = df['color'].str.contains("black") | |
df_grouped_color = (df.groupby(['weekday_num', 'weekday_name']) | |
['has_black'] | |
.value_counts() | |
.unstack() | |
.reset_index(level=0, drop=True)) | |
df_grouped_color |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
df_sample_grouped = df_sample.groupby(['birthday']).size() | |
n_unique_dates = len(df_sample_grouped.index.unique()) | |
fig = plt.figure(figsize=(n_unique_dates/5, n_unique_dates/10)) | |
ax = df_sample_grouped.plot.bar(x="birthday", y="n_pets", color='blue') | |
ax.set_xticklabels(labels=df_sample_grouped.index, rotation=70, rotation_mode="anchor", ha="right"); | |
ax.legend(labels=['n_pets']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n_sample = 50 | |
df_sample = df.sample(n=n_sample) | |
df_sample['birthday'] = (df_sample['date_of_birth'] | |
.dt | |
.strftime('%m-%d')) | |
df_sample_grouped = (df_sample | |
.groupby(['birthday']) | |
.size() | |
.reset_index(name="n_pets")) | |
df_sample_grouped.plot.bar(x="birthday", y="n_pets", color='blue'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df_grouped.plot.bar(x="weekday_name", y="n_pets", color='blue'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df['weekday_num'] = pd.DatetimeIndex(df['date_of_birth']).weekday | |
df['weekday_name'] = pd.DatetimeIndex(df['date_of_birth']).weekday_name | |
df_grouped = (df.groupby(['weekday_num', 'weekday_name']) | |
.size() | |
.reset_index(name="n_pets")) | |
df_grouped |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
filename = "aac_shelter_cat_outcome_eng.csv" | |
df = pd.read_csv(filename, | |
usecols=['name', 'date_of_birth', 'color'], | |
parse_dates=['date_of_birth']) | |
df.head() |