Question: do it in python 1. Import the proper libraries: Pandas and NumPy and create aliases pd, np respectively. 2. Load sample data (car_loan.csv) into data

do it in python

1. Import the proper libraries: Pandas and NumPy and create aliases pd, np respectively.

2. Load sample data (car_loan.csv) into data frame: df

3. Export Pandas DataFrames to csv. Save file name as out.csv. hint: help(df.to_csv)

4. Run the command: df.info (). What do you see, how many columns? also what about

number of entries for each column

5. It is often the case where you change your column names or remove unnecessary

columns.

a. Change the following columns names:

Starting Balance: starting_balance

Interest Paid: interest_paid

Principal Paid: principal_paid

New Balance': new_balance

b. Remove the two columns term, and Repayment.

6. Run the command: interest_missing = df['interest_paid'].isna(), what do you see ?

7. Can you fix the problem in 6 above? hint: use the function df.loc.

property DataFrame.loc: Access a group of rows and columns by label(s) or a boolean

array.

8. Find the total = amount of interest paid over the course of the loan

9. Find the sum of all values across all columns

10. Convert Pandas DataFrames to NumPy arrays

11. Import the library pyplot from matplotlib and create alias plt

12. import seaborn library (wrapper of matplotlib) and create alias: sns

13. load data out.csv

14. use the loc property to find the values of the followings: month_numbe, interest_paid,

principal_paid.

For example: month_number = df.loc[:, 'Month'].values will return:

array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,

18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,

35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,

52, 53, 54, 55, 56, 57, 58, 59, 60])

# The values attribute converts a column of values into a numpy array

15. Check the type of the month_number array?

16. Plot the interest paid vs the number of months.

17. On the same graph plot the principal paid vs the number of months

18. you can use plt.style.available to select an appropriate aesthetic styles for your figures.

Run the following command: plt.style.available, you should see a list of different styles.

19. Re-do 16 and 17 using the plt.style.use('classic'). What did you notice different?

20. Re-do 19 using the plt.style.use(fivethirtyeight). What did you notice different?

21. Re-do 19 using the plt.style.use(seaborn). What did you notice different?

22. Add legend to your figures. Add it to be "center right.

23. Add markers and colors. The interest_paid in Black, and principal_paid in blue

24. Setting plot titles, labels choose font size of 12

a. Set xlabel and ylabel : x:Month, y: Dollars

b. Set Title: Interest and Principal Paid Each Month

25. Saving plots to files.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!