Nov-14-2018, 04:58 PM
Hello!
New to python but I'm trying, all advice is appreciated.
I have a master data sheet which I have loaded into a data frame. I have then been able to hard-code a value from the "Delivery BA" column in to return a data frame with only that value. I have also been able to list and count the unique values in the column. I currently have a cell which displays a string value of the filter criteria selected for the "Delivery BA" column.
What I would IDEALLY like to do is to be able to prompt the user with a selection box containing all the unique values in the column, and then, upon the user selecting a value, pass that value to the dataframe parameters so that it creates a dataframe with only that "Delivery BA" for entries, preferably without needing to access the value passed in the filter string cell.
I have searched and searched so I apologize if this has been answered already, or something similar.
Please see what little code I have so far.
Explanation of variables:
d: The number of entries in the column "Delivery BA"
g: Not sure what I was doing here; I believe trying to identify the column as "Delivery BA"
h: Entries for a particular company in the column
j: Accessing the cell containing the string value of the selected filter criteria
q: This didn't do what I wanted; I'm not sure now what I wanted
x: Unique values in "Delivery BA" column
y: The number of unique values in "Delivery BA" column. At time of writing, it sits at 739.
New to python but I'm trying, all advice is appreciated.
I have a master data sheet which I have loaded into a data frame. I have then been able to hard-code a value from the "Delivery BA" column in to return a data frame with only that value. I have also been able to list and count the unique values in the column. I currently have a cell which displays a string value of the filter criteria selected for the "Delivery BA" column.
What I would IDEALLY like to do is to be able to prompt the user with a selection box containing all the unique values in the column, and then, upon the user selecting a value, pass that value to the dataframe parameters so that it creates a dataframe with only that "Delivery BA" for entries, preferably without needing to access the value passed in the filter string cell.
I have searched and searched so I apologize if this has been answered already, or something similar.
Please see what little code I have so far.
Explanation of variables:
d: The number of entries in the column "Delivery BA"
g: Not sure what I was doing here; I believe trying to identify the column as "Delivery BA"
h: Entries for a particular company in the column
j: Accessing the cell containing the string value of the selected filter criteria
q: This didn't do what I wanted; I'm not sure now what I wanted
x: Unique values in "Delivery BA" column
y: The number of unique values in "Delivery BA" column. At time of writing, it sits at 739.
import pandas
data = pandas.read_excel('Test Master.xlsx', header = None).values
print(data)
df = pandas.DataFrame(data)
new_header = df.iloc[0]
df = df[0:]
df.columns = new_header
d = df['Delivery BA'].value_counts()
print(d)
g = df.groupby('Delivery BA', as_index = False)
print(g)
h = df.loc[df['Delivery BA']== 'AmeriGas Propane, L.P.']
print(h)
j = df.iloc[0, 25]
print(j)
q = df.loc[df['Delivery BA'] == j]
print(q)
x = df['Delivery BA'].unique()
print(x)
y = df['Delivery BA'].nunique()
print(y)Apologies if I've posted anything arbitrary or not enough information. Thank you again.
