Data Cleaning with Pandas

I am trying to get started with the "Cleaning US Census Data project in the Data Cleaning with Pandas module. I am having trouble doing task 1.

Here is my code so far:

import pandas as pd
import numpy as np
import matplotlib.pyplot as pyplot
import codecademylib3_seaborn
import glob

files = glob.glob("\w+*.csv") #tried some other regex here.

df_list =
for filename in files:
data = pd.read_csv(filename)
df_list.append(data)

df = pd.concat(df_list)
print(df)

Hey!

Here’s what I have, which seems to work:

us_census = glob.glob("states*.csv")

df_list = []
for state in us_census:
  df_list.append(pd.read_csv(state))
  
us_census = pd.concat(df_list)

if you look in the navigator, all of the csv files started with “states” so you just glob them all together.
I think your mistake is that you defined “files” at first but then switched to df. if you change "df " to “files”:

then you should have:


files = glob.glob("states*.csv") 

df_list = 
for filename in files:
data = pd.read_csv(filename)
df_list.append(data)

*files* = pd.concat(df_list)
print(*files*)

I’m sorry if this was confusing, but I hope it helps!