Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Reduce the amount of data from chart plot matplotlib

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

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading