2021-12-11

Creating a new list from the data in the list with certain rules I have data from different csv files. These data are listed and include VAT 0 and total amounts. Apart from these two information, many other values are also present in my list. In the example, my total amount is 4000 and VAT is 0. According to my algorithm, it replaces 4000 with the largest and possibly irrelevant value. df=[26300.0, 17360.0, 4000.0, 4000.0, 4000.0, 4000.0, 6.575, 3.7, 0.0, 0.0, 0.0] The important point is that the lists vary. Example from my shared list unittest.

def zero_vat(df):
catch_list=[]
df.sort(reverse = True)
print(df)
for i, value in enumerate(df):  # 1.array
for j, value2 in enumerate(df):  # 2.array
if df[i]==0:
if df[i]+max(df)==df[j]:
temp_list=[]
temp_list.append(df[i])
temp_list.append(df[j])
temp_list.append(max(df))
catch_list.append(temp_list)
print(catch_list)
elif df[i]+0 == max(df):
temp_list=[]
temp_list.append(df[i])
temp_list.append(0.0)
temp_list.append(max(df))
catch_list.append(temp_list)
print(catch_list)
return catch_list

output : [[26300.0, 0.0, 26300.0]]
must be :[[4000.0,0.0,4.000]]

You may have missed 1 min read

Creating a new list from the data in the list with certain rules 2 min read

How can I close my hamburger menu when clicking on a link using React JS? (using ReactJS hooks) 1 min read

Java – Reading numbers (IDs) from file in one line separated by commas 1 min read