I would like to check a "worksheet" if it contains more than e.g. 250 entries if it does I would create a new excel-sheet and save it in a new file.
For example:
Leading-Zip: Adresses that contains the Leading-Zip:
--------------------------
74 400
73 200
72 50
I used this command to get the number of entries I want to group:
worksheet['Zip-code-region'].value_counts()
Which way do I have to choose to make that? Do i have to create a list? or could I use a command with a for-loop?
Try a Update: I am importing a excelfile:
xel = pd.read_excel(r'C:test.xlsx', sheet_name = None)
than i select a sheet:
worksheet = xel[ws]
now I add a new column 'leading-zip' slicing the ZIP code:
worksheet['leading-zip']=worksheet['zip-code'].astype(str).str[:2].astype(int)
from that 'leading-zip' I want to iterate each 'leading-zip' - count the adresses contained in it and if they are more than 250 I want to create a new excel file.