Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
table = pd.pivot_table(df, values='Quantity', index =['Country','Region'], columns=["Year","Requester"], aggfunc=[np.sum]) | |
result_df = table | |
for i in range(2): | |
df2 = table.groupby(level=i).sum() | |
if i==0: | |
tot_sum = df2.sum(axis=i) | |
df2 = pd.concat([df2,pd.DataFrame([tot_sum]).rename({0:"Grand"})]).sort_index(level=[0]) | |
df2.index = pd.MultiIndex.from_arrays([df2.index.values + '_Total', | |
len(df2.index) * [''], | |
len(df2.index) * ['']]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@login_required | |
def addtoprofile(request, count): | |
count = int(count) | |
formsets = (Form1, Form2, Form3) | |
try: | |
Form = Form[count] | |
except IndexError: | |
return redirect("/") | |
next_url = "Next" | |
if count == len(formsets): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def instantiate_formset_data(formset_class, data, instances=[], initial=None, action="add"): | |
""" | |
Input: | |
Formset_class | |
data - Python Dict type form data | |
Instances - [] if its a CreateForm, or list of instances in case of EditForm | |
Initial - Initial data if any | |
Action = define edit/Add action | |
Output: data --> Formset style Data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def configure_fields(fields): | |
""" | |
Configures form field with bootstrap style | |
Input forms fields | |
Output formatted form fields | |
""" | |
for field in fields: | |
if isinstance(fields[field].widget, Textarea): | |
fields[field].widget.attrs['rows'] = '3' | |
fields[field].widget.attrs['class'] = 'form-control' |
NewerOlder