Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I wrote the code below produce a report in Jupyter notebook that provides the following information. Please could someone help refine this with following points:
I wrote the code below produce a report in Jupyter notebook that provides the following information. Please could someone help refine this with following points: how to remove 'Name: Income, dtype: float and 'Name: count, dtype: int how to round income balance numbers to decimal pointsIn : import pandas as pd # Create a DataFrame with balance.txt df pdreadcsvbalancetxt seps # Compare the average income based on ethnicity printAverage income by ethnicity:" printdfgroupbyEthnicityIncomemean # On average, do married or single people have a higher balance? # calculate the average balance of married and single person Married "Yes"loc: "Balance"mean print Average balance of married person:" print bm Married Noloc: "Balance"mean print Average balance of single person:" printbu # check if balance of married person balance of unmarried perosn if bu: # if yes, display print Married people have a higher balance than single people. # check if balance of unmarried person balance of married perosn if bu : # if yes, display print Single people have a higher balance than married people. # What is the highest income in our dataset? print Highest income:" printdfIncomemax # What is the lowest income in our dataset? print Lowest income:" printdfIncomemin # How many cards do we have recorded in our dataset? print Total number of cards:" printdfCardssum # How many females do we have information for vs how many males? print Number of females and males:" printdfGendervaluecounts
I wrote the code below produce a report in Jupyter notebook that provides the following information. Please could someone help refine this with following points:
how to remove 'Name: Income, dtype: float and 'Name: count, dtype: int
how to round income balance numbers to decimal pointsIn : import pandas as pd
# Create a DataFrame with balance.txt
df pdreadcsvbalancetxt seps
# Compare the average income based on ethnicity
printAverage income by ethnicity:"
printdfgroupbyEthnicityIncomemean
# On average, do married or single people have a higher balance?
# calculate the average balance of married and single person
Married "Yes"loc: "Balance"mean
print
Average balance of married person:"
print bm
Married Noloc: "Balance"mean
print
Average balance of single person:"
printbu
# check if balance of married person balance of unmarried perosn
if bu:
# if yes, display
print
Married people have a higher balance than single people.
# check if balance of unmarried person balance of married perosn
if bu :
# if yes, display
print
Single people have a higher balance than married people.
# What is the highest income in our dataset?
print
Highest income:"
printdfIncomemax
# What is the lowest income in our dataset?
print
Lowest income:"
printdfIncomemin
# How many cards do we have recorded in our dataset?
print
Total number of cards:"
printdfCardssum
# How many females do we have information for vs how many males?
print
Number of females and males:"
printdfGendervaluecounts
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started