1

Hello I have this code below where I'm supposed to display the plot of only 15 amounts of data from 'Apps' column and 'Total Downloaded' column. The thing is there's total 100 rows which I want to reduce column 'Apps' and 'Total Downloaded' to 15 and plot them. How do I do that?

import pandas as pd 
import matplotlib.pyplot as plt 
data = pd.read_excel("C:\\users\\HP\\Documents\\Datascience task\\Apps.xlsx")

data = data.rename(columns={'Total Downloads (Per Thousand)': 'Total Downloaded'})

apps = sorted(data['Apps']) # * Display only 15 apps
total_downloads = sorted(data['Total Downloaded']) # * Display 15 data of total downloaded

# * Plot the amount of downloaded app and thier name
plt.plot(total_downloads,apps) # * X , Y
plt.xlabel('Total Downloaded (Per Thousand)')
plt.ylabel("Apps")

data
1
  • Do you need top 15 Total Downloaded values? Are Apps unique in column or duplicated? Commented Jan 11, 2022 at 6:35

1 Answer 1

1

If need first 15 values:

data1 = data.rename(columns={'Total Downloads (Per Thousand)': 'Total Downloaded'}).head(15)

If need first top15 by Total Downloaded use:

data1 = (data.rename(columns={'Total Downloads (Per Thousand)': 'Total Downloaded'})
             .nlargest(15, 'Total Downloaded'))

And then sorting is not necessary, use:

plt.plot(data1['Total Downloaded'],data1['Apps']) # * X , Y
plt.xlabel('Total Downloaded (Per Thousand)')
plt.ylabel("Apps")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.