0
frame = pd.DataFrame()
for i in range (1995,2020):
  file_name = f"{i}"
  df = pd.read_csv(BytesIO(uploaded["%s.csv"%file_name]))
  df = pd.DataFrame(data, columns= ['DATE','ARANGALI'])
  frame.append(df)
print(frame)

I tried to define a function to append all the the data I have into one dataframe. The output appears to be an empty dataframe.

Empty DataFrame; Columns: []; Index: [].

The code works if consider the variables frame and df as lists and appends up to a large list. But I want a dataframe with all the data under the same column heads. What am I doing wrong?

1 Answer 1

1

Append method returns a new DataFrame. Docs.

frame = pd.DataFrame()
for i in range (1995,2020):
  file_name = f"{i}"
  df = pd.read_csv(BytesIO(uploaded["%s.csv"%file_name]))
  df = pd.DataFrame(data, columns= ['DATE','ARANGALI'])
  frame = frame.append(df)
print(frame)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.