Aug-06-2019, 03:44 PM
(This post was last modified: Aug-06-2019, 03:45 PM by eddywinch82.)
I included the following Code :-
To filter out rows, that have only 1 of each BID Number, it does that, but it now includes the other Data which I wanted excluding, how do I use this Groupby Code, in the rest of my Code, to achieve the result I wan't ?
The current order is :-
I have # out the groupby part of my Code.
And I get the Following Traceback Error :-
df.groupby('BID').filter(lambda x : len(x)>1)at the end of my Python Code.
To filter out rows, that have only 1 of each BID Number, it does that, but it now includes the other Data which I wanted excluding, how do I use this Groupby Code, in the rest of my Code, to achieve the result I wan't ?
The current order is :-
import pandas as pd xls = pd.ExcelFile(r'C:\Users\Edward\Desktop\BBMF Schedules And Master Forum Thread Texts\BBMF Display Schedule 2009.xls') data = pd.read_excel(xls, sheet_name="Sheet1") pd.options.display.max_rows = 1000 df = pd.DataFrame(data, columns= ['Venue','A/C','DISPLAY/','Date','BID']) df[(df['Venue'].str.contains('[a-zA-Z]') & (df['DISPLAY/'].str.contains('DISPLAY') & df['A/C'].str.contains("DHS|DAK|HS|SPIT")) & (df['A/C'] != 'LHS') & (df['A/C'] != 'LANC'))] df.groupby('BID').filter(lambda x : len(x)>1)I have added a code onto the end of my Python Code, My Code now ends :-
df[(df['Venue'].str.contains('[a-zA-Z]') & (df['DISPLAY/'].str.contains('DISPLAY') & df['A/C'].str.contains("DHS|DAK|HS|SPIT")) & (df['A/C'] != 'LHS') & (df['A/C'] != 'LANC')) & df['BID'].value_counts(">1")]But even with the latest Code, added on the end, Some of the relevant data is being missed out , where have I gone wrong ?
I have # out the groupby part of my Code.
And I get the Following Traceback Error :-
Error:c:\python37\lib\site-packages\ipykernel_launcher.py:11: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
# This is added back by InteractiveShellApp.init_path()