<jupyter_start><jupyter_text>Instructor Demo: Pandas VisualizationsThis program reads annual gold price data from a CSV and uses line and bar charts to visualize the data.<jupyter_code># Import libraries and dependencies
import pandas as pd
from pathlib import Path

# Set the Pandas plots to be displayed in the notebooks canvas
%matplotlib inline<jupyter_output><empty_output><jupyter_text>1. Read in CSV<jupyter_code># Set the file path
file_path = Path("../Resources/annual_gold.csv")

# Read in the CSV as a DataFrame
gold_csv = pd.read_csv(file_path)
gold_csv.head()<jupyter_output><empty_output><jupyter_text>2. Plot Data Without Datetime Index<jupyter_code># Plot a line chart of the data without setting the 'Date' column as the index
gold_csv.plot()<jupyter_output><empty_output><jupyter_text>3. Set Date as Index<jupyter_code># Convert date strings into datetime objects and set the datetime as the index
gold_csv = gold_csv.set_index(pd.to_datetime(gold_csv["Date"], infer_datetime_format=True))
gold_csv.head()<jupyter_output><empty_output><jupyter_text>4. Drop Extra Columns<jupyter_code># Drop the extra date column
gold_csv = gold_csv.drop(columns=["Date"])
gold_csv.head()<jupyter_output><empty_output><jupyter_text>5. Plot Data with Datetime Index<jupyter_code># Plot a line char of the data after converting and setting the 'Date' column as the datetime index
gold_csv.plot()<jupyter_output><empty_output><jupyter_text>6. Plot Bar Chart<jupyter_code># Plot a bar chart of the data
gold_csv.plot(kind="bar")<jupyter_output><empty_output><jupyter_text>7. Plot Bar Chart with Increased Figure Size<jupyter_code># Plot a bar chart of the data with increased figure size to see the x-axis labels
gold_csv.plot(kind="bar", figsize=(20,10))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08922558922558922, 'fraction_numerical': 0.006172839506172839, 'mean_word_length': 7.370892018779343, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, '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': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '103413', 'license': 'ADSL', 'n_tokens_mistral': 596, 'n_tokens_neox': 585, 'n_words': 180, 'path': 'Starter_Code/.ipynb_checkpoints/visualization-checkpoint.ipynb', 'repo_name': 'you915/Create-a-custom-portfolio-of-stocks', 'size': '1782'}