Question

UPDATED:
Hi, I have a problem in PYTHON I've been trying to solve. I'm given two csv files containing data in the following format of a micro car that moves around:

Action, time, speed. (e.g. N,t,s= Move North for t seconds with speed s meters per second)

One list is the expected results, the second list is the actual (recorded) results.

The car can move N,S,E,W. The data entry will look like this: (CSV files)

Expected: N 10 18 S 10 16 W 95Actual: N 10 10 E 10 8 S 10 5 W 10 4

I am trying to get the function to return:

The expected horizontal displacements for each microcar • The expected vertical displacements for each microcar • The actual horizontal displacements for each microcar • The actual vertical displacements for each microcar • The expected distances travelled by each microcar • The actual distances travelled by each microcar

All in numpy arrays. Could someone please show me a test solution, Thank you

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import numpy as np

# expected data is in expected.csv and actual data is in actual.csv

exp = np.genfromtxt("expected.csv", delimiter=",", usecols=(1,2)) # read csv into numpy array
actual = np.genfromtxt("actual.csv", delimiter=",", usecols=(1,2)) # usecols=(1,2) used to read 1st and 2nd column, skipping N,E,S,W variables while reading

print("Expected horizontal displacement foar each microcar")
print(exp[1][0]*exp[1][1] - exp[3][0]*exp[3][1])


print("Expected vertical displacement foar each microcar")
print(exp[0][0]*exp[0][1] - exp[2][0]*exp[2][1])


print("Actual horizontal displacement foar each microcar")
print(actual[1][0]*actual[1][1] - actual[3][0]*actual[3][1])


print("Actual vertical displacement foar each microcar")
print(actual[0][0]*actual[0][1] - actual[2][0]*actual[2][1])

print("Expected distances travelled by each microcar")
print(exp[0][0]*exp[0][1]+exp[1][0]*exp[1][1]+exp[2][0]*exp[2][1]+exp[3][0]*exp[3][1])

print("Actual distances travelled by each microcar")
print(actual[0][0]*actual[0][1]+actual[1][0]*actual[1][1]+actual[2][0]*actual[2][1]+actual[3][0]*actual[3][1])

Add a comment
Know the answer?
Add Answer to:
UPDATED: Hi, I have a problem in PYTHON I've been trying to solve. I'm given two csv files containing data in th...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I'm not sure how to enter the data. I've tried and it looks wrong. Also C, D, E, F is what I need...

    I'm not sure how to enter the data. I've tried and it looks wrong. Also C, D, E, F is what I need help with as well. I've attached a copy of my output please tell me what I am doing wrong. I would like to know how to enter the data correctly. Out put I keep getting but it looks as if it's off. what am I doing wrong? Exercise for Chapter 17 You will be analyzing the data...

  • Python Help Please! This is a problem that I have been stuck on.I am only suppose...

    Python Help Please! This is a problem that I have been stuck on.I am only suppose to use the basic python coding principles, including for loops, if statements, elif statements, lists, counters, functions, nested statements, .read, .write, while, local variables or global variables, etc. Thank you! I am using python 3.4.1. ***( The bottom photo is a continuation of the first one)**** Problem statement For this program, you are to design and implement text search engine, similar to the one...

  • really need help i have been working on this for hours and barely made any progress,...

    really need help i have been working on this for hours and barely made any progress, please complete second portion of hw problem from requirments 2-7 Requirements 1. Prepare Trenton's operating budget and cash budget for 2019 by quarter. Required schedules and budgets include: sales budget, production budget direct materials budget, direct labor budget, manufacturing overhead budget, cost of goods sold budget, selling and administrative expense budget, schedule of cash receipts, schedule of cash payments, and cash budget. Manufacturing overhead...

  • I have this case study to solve. i want to ask which type of case study...

    I have this case study to solve. i want to ask which type of case study in this like problem, evaluation or decision? if its decision then what are the criterias and all? Stardust Petroleum Sendirian Berhad: how to inculcate the pro-active safety culture? Farzana Quoquab, Nomahaza Mahadi, Taram Satiraksa Wan Abdullah and Jihad Mohammad Coming together is a beginning; keeping together is progress; working together is success. - Henry Ford The beginning Stardust was established in 2013 as a...

  • I need Summary of this Paper i dont need long summary i need What methodology they used , what is the purpose of this...

    I need Summary of this Paper i dont need long summary i need What methodology they used , what is the purpose of this paper and some conclusions and contributes of this paper. I need this for my Finishing Project so i need this ASAP please ( IN 1-2-3 HOURS PLEASE !!!) SPECIAL ARTICLES tole of Monetary Policy C Rangarajan What should be the objectives of monetary policy? Does the objective of price stability conflict with the goal of achieving...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT