<jupyter_start><jupyter_text>Load Data<jupyter_code># Load car loan data into a pandas dataframe from a csv file
filename = 'data/table_i702t60.csv'
df = pd.read_csv(filename)
# View the first 5 rows of the dataframe
df.head()
# Checking to make sure we dont have nans in our dataframe
# It is not easy to directly plot data that contains nans
df.info()
# For this notebook we will graph interest_paid, principal_paid, and month on one graph
# While we could graph directly through pandas, we will graph through matplotlib for now.
month_number = df.loc[:, 'month'].values
interest_paid = df.loc[:, 'interest_paid'].values
principal_paid = df.loc[:, 'principal_paid'].values
month_number
# The values attribute converts a column of values into a numpy array
type(month_number)<jupyter_output><empty_output><jupyter_text>Grids<jupyter_code>plt.plot(month_number, interest_paid, c= 'k')
plt.plot(month_number, principal_paid, c = 'b')<jupyter_output><empty_output><jupyter_text>MATLAB-style<jupyter_code>plt.plot(month_number, interest_paid, c= 'k')
plt.plot(month_number, principal_paid, c = 'b')
plt.grid()
# only horizontal grid lines
plt.plot(month_number, interest_paid, c= 'k')
plt.plot(month_number, principal_paid, c = 'b')
plt.grid(axis = 'y')
# only vertical grid lines
plt.plot(month_number, interest_paid, c= 'k')
plt.plot(month_number, principal_paid, c = 'b')
plt.grid(axis = 'x')
# change color of grid lines, transparency, and linestyle
plt.plot(month_number, interest_paid, c= 'k')
plt.plot(month_number, principal_paid, c = 'b')
plt.grid(c = 'g', 
         alpha = .9,
         linestyle = '-')<jupyter_output><empty_output><jupyter_text>Object-oriented<jupyter_code>fig, axes = plt.subplots(nrows = 1, ncols = 1);
axes.plot(month_number, interest_paid, c= 'k');
axes.plot(month_number, principal_paid, c = 'b');
axes.grid()
# only horizontal grid lines
fig, axes = plt.subplots(nrows = 1, ncols = 1);
axes.plot(month_number, interest_paid, c= 'k');
axes.plot(month_number, principal_paid, c = 'b');
axes.grid(axis = 'y')
# only vertical grid lines
fig, axes = plt.subplots(nrows = 1, ncols = 1);
axes.plot(month_number, interest_paid, c= 'k');
axes.plot(month_number, principal_paid, c = 'b');
axes.grid(axis = 'x')
# change color of grid lines, transparency, and linestyle
fig, axes = plt.subplots(nrows = 1, ncols = 1);
axes.plot(month_number, interest_paid, c= 'k');
axes.plot(month_number, principal_paid, c = 'b');
axes.grid(c = 'g', 
          alpha = .9,
          linestyle = '-')
# if you are finding setting grids to be tedious, use a style that has grids
plt.style.use('seaborn')
fig, axes = plt.subplots(nrows = 1, ncols = 1);
axes.plot(month_number, interest_paid, c= 'k');
axes.plot(month_number, principal_paid, c = 'b');<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1372619475386274, 'fraction_numerical': 0.0064678404599353215, 'mean_word_length': 5.581560283687943, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '265712', 'license': 'MIT', 'n_tokens_mistral': 1029, 'n_tokens_neox': 970, 'n_words': 276, 'path': 'Introduction/hewei-material/6.Reporting_Virtualization/5.Grids.ipynb', 'repo_name': 'starswish2100/pythoninfinance', 'size': '2783'}