Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello Experts I have multiple files generated using Dataframes . These are placed in /tmp path as input1.csv , input2.csv, input3.csv and goes on .

Hello Experts

I have multiple files generated using Dataframes . These are placed in /tmp path as

input1.csv , input2.csv, input3.csv and goes on .

If the below code is used , it gives me an error stating "ValueError: No objects to concatenate" . If i place the files manually , the code works with concat logic .

However when i run the entire logic - before my process creates the csv files , it tries to concatenate and shows the above error . Any suggestions how to handle this case ?

import pandas as pd import glob path = "/tmp" # use your path all_files = glob.glob(path + "/*.csv") li = [] for filename in all_files: df = pd.read_csv(filename, index_col=None, header=0) li.append(df) frame = pd.concat(li, axis=0, ignore_index=True) 

How do we ensure before running

frame = pd.concat(li, axis=0, ignore_index=True) 

step , the .csv files are checked to be present and then concatenate

Note : Continuation question from https://www.coursehero.com/qa/wait/31264255/

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions