<jupyter_start><jupyter_text>Consumer Price Index DataFrame exampleBy [<NAME>](http://palewi.re/who-is-ben-welsh/)A rudimentary example of how to import Consumer Price Index data published by the U.S. Bureau of Labor Statistics into a pandas DataFrame using the [cpi](https://github.com/datadesk/cpi) open-source Python wrapper.   Access the libraryYou will not need to do this if you install the library from PyPI. To do that, simply run:```$ pip install cpi```<jupyter_code>import os
import sys
this_dir = os.path.dirname(os.getcwd())
sys.path.insert(0, this_dir)<jupyter_output><empty_output><jupyter_text>Import the cpi library itself.This everyone will want to do.<jupyter_code>import cpi<jupyter_output><empty_output><jupyter_text>Access a list of all CPI series in a DataFrame The `to_dataframe` method on cpi's series list is ready to serve.<jupyter_code>series_df = cpi.series.to_dataframe()
series_df.info()
series_df.head()<jupyter_output><empty_output><jupyter_text>Access all the indexes for a single series in a DataFrame. Pull an individual series from cpi.<jupyter_code>series_obj = cpi.series.get(
    items="Housing",
    area="Los Angeles-Long Beach-Anaheim, CA"
)
series_obj<jupyter_output><empty_output><jupyter_text>Call `to_dataframe` to receive all indexes in a DataFrame.<jupyter_code>index_df = series_obj.to_dataframe()
index_df.info()
index_df.head()<jupyter_output><empty_output><jupyter_text>Now let's show off a little and make a chartImport Altair and you can rip right away.<jupyter_code>import altair as alt<jupyter_output><empty_output><jupyter_text>Here's a chart of all the annual values in in the series I pulled above.<jupyter_code>alt.Chart(index_df, title="Consumer Price Index of L.A. area housing costs by year").mark_bar().encode(
    x=alt.X("year:O", axis=alt.Axis(title="")),
    y=alt.Y("value:Q", axis=alt.Axis(title=""))
).transform_filter(
    # We will filter down to annual values to simplify things and drop the monthly values.
    alt.datum.period_name == 'Annual Average'
)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10587663914521613, 'fraction_numerical': 0.00048567265662943174, 'mean_word_length': 6.177700348432055, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 30, 'https://': 1, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '538704', 'license': 'MIT', 'n_tokens_mistral': 695, 'n_tokens_neox': 682, 'n_words': 199, 'path': 'notebooks/dataframes.ipynb', 'repo_name': 'chekos/cpi', 'size': '2062'}