Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a loop to process multiple files I have written the code below but currently I need to retype the same conditions for each file

Create a loop to process multiple files

I have written the code below but currently I need to retype the same conditions for each file and, as there are over 100 files, this is not ideal.

I couldn't come up with a way to implement this using a loop that will read all of these files and filter the values in MP out. Meanwhile, adding two new columns to each filter file as the written code below would be the only method I know so far. I try to obtain a new combined data frame with all filter files with their conditions

Please suggest ways of implementing this using a loop:

image text in transcribed

import pandas as pd import matplotlib.pyplot as plt import numpy as np from scipy import signal dfi = pd.read_csv('E:\Unmanned Cars\Unmanned Cars\2017040810_052.csv') df2 = pd.read_csv('E:\Unmanned Cars\Unmanned Cars\2017040901_052.csv') df3 = pd.read_csv('E:\Unmanned Cars\Unmanned Cars\2017040902_052.csv') df1 =df1["MP"].unique) df1=pd.DataFrame(dfi, columns=['MP']) df1["Dates"] = "2017-04-08" df1["Inspection"] = "10" ## df2 =df2["MP"]. unique) df2=pd.DataFrame(df2, columns=['MP']) df2["Dates"] = "2017-04-09" df2["Inspection"] = "01" ## df3 =df3["MP"]. unique) df3=pd. DataFrame(df3, columns=['MP']) df3["Dates"] = "2017-04-09" df3["Inspection"] = "02" Final = pd.concat([dfi, df2, df3, df4], axis = 0, sort = False)

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

Advances In Databases And Information Systems 23rd European Conference Adbis 2019 Bled Slovenia September 8 11 2019 Proceedings Lncs 11695

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Aida Kamisalic Latific

1st Edition

3030287297, 978-3030287290

More Books

Students also viewed these Databases questions

Question

What advice would you provide to Jennifer?

Answered: 1 week ago

Question

What are the issues of concern for each of the affected parties?

Answered: 1 week ago