![]() |
How to use the count function from an Excel file using Python? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: How to use the count function from an Excel file using Python? (/thread-31580.html) |
How to use the count function from an Excel file using Python? - jpy - Dec-20-2020 Hello everyone - I am in the early stages of learning Python and decided to start with using Excel in Python. I am running the code below in Jupyter and it works well. This notebook currently has a state column and a country column. I would like to count the total number of states but I don't know how to reference the columns - could anyone please tell me how to start? I tried the second code below but that did not run. import pandas as pd df = pd.read_excel (r'C:\Users\Family\Desktop\Anaconda\Book1.xlsx') print (df) st = 'State'.count() RE: How to use the count function from an Excel file using Python? - snippsat - Dec-21-2020 You most always have have reference to the DataFrame,which now stored in variable df . print(df['State'].count()) RE: How to use the count function from an Excel file using Python? - jpy - Dec-21-2020 Thank you for the guidance and reading, I appreciate it. |