PART 1 - You will write a python program to generate a Pandas data frame of rand
ID: 3681600 • Letter: P
Question
PART 1 -
You will write a python program to generate a Pandas data frame of random test data. This data will be stored as an Excel workbook. In order to generate random data, you will need to write functions like the following:
import pandas as pd
import numpy as np
def create_random_state(n):
states = ['MO', 'IN', 'TN', 'TX', 'NY', 'OH']
rs = np.random.choice(states, n, replace=True)
return list(rs)
You need to generate 10,000 records containing the following fields and written to an Excel Workbook using Pandas:
* First Name (Given Name) – Have at least 20 options.
* Last Name (Last Name) – Have at least 20 options.
* Gender – Male/Female. Should match name (Sue is Female)
* Region – Have at least 10. These can be US States.
* Age – Reported in decades: 1 for teens, 2 for twenties, and so forth
* Customer Id – Random string of the form: A123-e7. First character is a capital alphabetic, then 3 digits a hyphen and a digit.
* Loan – A large random number in whatever currency
* Principal – Random Amount paid, less than loan
* Owed – Difference between Loan and Principal
* Interest Due – Keep it simple. Just 20% of Owed
Explanation / Answer
-----
---------
Creating a DataFrame by pa
----------
---------------
----------------------
------------------------'
-----------------------------------
Here the program is split into different modules seperated bu dashed lines.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.