Python Forum

Full Version: Counting of rows in Excel Spreadsheet
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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')'seaborn-dark')

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.

Thanks @jefsummers, got it fixed and thanks for the inspiration!