Jul-16-2020, 10:00 PM
(Jul-16-2020, 11:24 AM)palladium Wrote: Hmm, maybe try using pandas to convert the range of cells you are interested in into a series, and then use the value_count() function to take it from there? Something like:
import pandas as pd series = pd.read_excel(filename, sheetname, skiprows = [0:5],usecols = "F", squeeze = True) # I'll let you enter the filename and sheetname. Make sure squeeze is True so that you end up with a Series, not a dataframe. counts = series.value_counts() z = counts[0]...and then write z to the cell you want with openpyxl.
More info: https://pandas.pydata.org/pandas-docs/st...excel.html, https://pandas.pydata.org/pandas-docs/st...ounts.html
Credits: https://stackoverflow.com/questions/1220...e-variable
Hello,
This code doesn't work I end up this error message
counts = series.value_counts()
AttributeError: 'collections.OrderedDict' object has no attribute 'value_counts'