ComenzarEmpieza gratis

Creating new columns

Personal consumption expenditures (PCE) are a measurement of consumer consumption useful in judging the state and direction of the economy. Pretend that you are a financial analyst at an investment fund tasked with calculating PCE. PCE is the sum of consumption by consumers of durable goods (PCDG), non-durable goods (PCND), and services (PCESV). Let's calculate PCE using the list pcesv, the DataFrame pcnd, and PCDG from a CSV file.

Este ejercicio forma parte del curso

Intermediate Python for Finance

Ver curso

Instrucciones del ejercicio

  • Create a column named PCESV from a list of values pcesv.
  • Create a column named PCND from the DataFrame pcnd.
  • Use the function .read_csv() to create a column named PCD' from the CSV file pcdg.csv.
  • Create a new column named PCE by adding other columns together.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# Use the list pcesv to create the column PCESV
pce[____] = pcesv

# Use the DataFrame pcnd to create the column PCND
____ = pcnd

# Create column for PCDG using Pandas read_csv
pce['PCDG'] = pd.____('pcdg.csv', index_col='DATE')

# Create a column PCE by adding values from other columns
pce['PCE'] = pce['PCDG'] ____ pce['____'] + ____
pce.head()
Editar y ejecutar código