Python Forum
Counting of rows in Excel Spreadsheet
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Counting of rows in Excel Spreadsheet
#1
Howdy! Am a newbie, appreciate any guidance shared.

Given an excel with data with rows of information with a Field called cities: Melbourne, Singapore, Kuala Lumpur, New York.

How do I code to generate a graph counting how many entries belong e.g. to Melbourne / Singapore / and all the other cities? Trying for a horizontal or vertical bar chart for display.

Big thanks!

import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np

df = pd.read_excel (r'C:\Users\Data20192020.xlsx')

plt.style.use('seaborn-dark')

plt.plot(df['Cities'].value_counts())
plt.show()
Reply
#2
df.value_counts() The Docs

Pandas has an amazing number of functions and features. Worth spending some time with it. Pandas from the ground up is a youtube video from PyCon 2015. 2.5 hours so it is a time commitment, but IMHO worth it.

Video
Reply
#3
Thanks @jefsummers, got it fixed and thanks for the inspiration!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Excel Rows to sentences spartak315 0 1,741 Aug-24-2018, 07:48 PM
Last Post: spartak315
  How do I write a line of code into an excel spreadsheet using Python code? Emerogork 2 3,152 Feb-07-2018, 06:54 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020