SantanuBanerjee commited on
Commit
2d6a87c
·
verified ·
1 Parent(s): 3fca7f2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +86 -6
app.py CHANGED
@@ -3,13 +3,95 @@ import pandas as pd
3
 
4
 
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
 
8
  def nlp_pipeline(original_df):
9
- print("Inside the NLP Pipeline")
10
- original_df['Sum'] = original_df['a'] + original_df['b']
11
- print(original_df)
12
- return original_df
13
 
14
 
15
 
@@ -22,8 +104,6 @@ def process_excel(file):
22
 
23
  # Perform any processing on the DataFrame here
24
  # Example: adding a new column with the sum of two other columns
25
- # df['Sum'] = df['Column1'] + df['Column2']
26
- print("Hello")
27
  result_df = nlp_pipeline(df)
28
 
29
 
 
3
 
4
 
5
 
6
+ def data_pre_processing(file_responses):
7
+ # Financial Weights are in per decas and NOT per cents
8
+
9
+ ### GPT: Assuming 'Your financial allocation for Problem (in $)' column contains numerical values
10
+
11
+ file_responses['''Your financial allocation for Problem 1:
12
+ Mention the percentage of your Tax Amount which you wish the Government would allocate through their annual budget, to implement a specific solution for your 1st problem.'''] = pd.to_numeric(file_responses['''Your financial allocation for Problem 1:
13
+ Mention the percentage of your Tax Amount which you wish the Government would allocate through their annual budget, to implement a specific solution for your 1st problem.'''], errors='coerce').fillna(0)
14
+
15
+ file_responses['''Your financial allocation for Problem 2:
16
+ Mention the percentage of your Tax Amount which you wish the Government would allocate through their annual budget, to implement a solution specifically to your 2nd problem.'''] = pd.to_numeric(file_responses['''Your financial allocation for Problem 2:
17
+ Mention the percentage of your Tax Amount which you wish the Government would allocate through their annual budget, to implement a solution specifically to your 2nd problem.'''], errors='coerce').fillna(0)
18
+
19
+ file_responses['''Your financial allocation for Problem 3:
20
+ Mention the percentage of your Tax Amount which you wish the Government would allocate through their annual budget, to implement a solution specifically to your 3rd problem.'''] = pd.to_numeric(file_responses['''Your financial allocation for Problem 3:
21
+ Mention the percentage of your Tax Amount which you wish the Government would allocate through their annual budget, to implement a solution specifically to your 3rd problem.'''], errors='coerce').fillna(0)
22
+
23
+ file_responses['''How much was your latest Tax payment (in U$D) ?
24
+
25
+ Please try to be as accurate as possible:
26
+ Eg.: If your last tax amount was INR 25,785/-; then convert it in U$D and enter only the amount as: 310.
27
+
28
+ If you have never paid tax, consider putting in a realistic donation amount which wish to contribute towards helping yourself obtain the desired relief.'''
29
+ ] = pd.to_numeric(file_responses['''How much was your latest Tax payment (in U$D) ?
30
+
31
+ Please try to be as accurate as possible:
32
+ Eg.: If your last tax amount was INR 25,785/-; then convert it in U$D and enter only the amount as: 310.
33
+
34
+ If you have never paid tax, consider putting in a realistic donation amount which wish to contribute towards helping yourself obtain the desired relief.'''
35
+ ], errors='coerce').fillna(0)
36
+
37
+
38
+
39
+
40
+
41
+ # Adding a new column 'Total Allocation' by summing specific columns by their names
42
+ file_responses['Total Allocation'] = file_responses[['''Your financial allocation for Problem 1:
43
+ Mention the percentage of your Tax Amount which you wish the Government would allocate through their annual budget, to implement a specific solution for your 1st problem.''' , '''Your financial allocation for Problem 2:
44
+ Mention the percentage of your Tax Amount which you wish the Government would allocate through their annual budget, to implement a solution specifically to your 2nd problem.''' , '''Your financial allocation for Problem 3:
45
+ Mention the percentage of your Tax Amount which you wish the Government would allocate through their annual budget, to implement a solution specifically to your 3rd problem.''']].apply(lambda x: x.clip(lower=10)).sum(axis=1)
46
+
47
+
48
+
49
+
50
+
51
+ # Creating 'Financial Weight' column by dividing 'Your financial allocation for Problem 1' by 'Total Allocation' and multiplying this with the assigned decage (similar to percentage but for 10) for Problem 1
52
+ file_responses['Financial Token Weight for Problem 1'] = file_responses['''How much was your latest Tax payment (in U$D) ?
53
+
54
+ Please try to be as accurate as possible:
55
+ Eg.: If your last tax amount was INR 25,785/-; then convert it in U$D and enter only the amount as: 310.
56
+
57
+ If you have never paid tax, consider putting in a realistic donation amount which wish to contribute towards helping yourself obtain the desired relief.'''
58
+ ] * file_responses['''Your financial allocation for Problem 1:
59
+ Mention the percentage of your Tax Amount which you wish the Government would allocate through their annual budget, to implement a specific solution for your 1st problem.'''] / file_responses['Total Allocation']
60
+
61
+
62
+ file_responses['Financial Token Weight for Problem 2'] = file_responses['''How much was your latest Tax payment (in U$D) ?
63
+
64
+ Please try to be as accurate as possible:
65
+ Eg.: If your last tax amount was INR 25,785/-; then convert it in U$D and enter only the amount as: 310.
66
+
67
+ If you have never paid tax, consider putting in a realistic donation amount which wish to contribute towards helping yourself obtain the desired relief.'''
68
+ ] * file_responses['''Your financial allocation for Problem 2:
69
+ Mention the percentage of your Tax Amount which you wish the Government would allocate through their annual budget, to implement a solution specifically to your 2nd problem.'''] / file_responses['Total Allocation']
70
+
71
+
72
+ file_responses['Financial Token Weight for Problem 3'] = file_responses['''How much was your latest Tax payment (in U$D) ?
73
+
74
+ Please try to be as accurate as possible:
75
+ Eg.: If your last tax amount was INR 25,785/-; then convert it in U$D and enter only the amount as: 310.
76
+
77
+ If you have never paid tax, consider putting in a realistic donation amount which wish to contribute towards helping yourself obtain the desired relief.'''
78
+ ] * file_responses['''Your financial allocation for Problem 3:
79
+ Mention the percentage of your Tax Amount which you wish the Government would allocate through their annual budget, to implement a solution specifically to your 3rd problem.'''] / file_responses['Total Allocation']
80
+
81
+ return file_responses
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
 
90
 
91
  def nlp_pipeline(original_df):
92
+ processed_df = data_pre_processing(original_df)
93
+ #original_df['Sum'] = original_df['a'] + original_df['b']
94
+ return processed_df
 
95
 
96
 
97
 
 
104
 
105
  # Perform any processing on the DataFrame here
106
  # Example: adding a new column with the sum of two other columns
 
 
107
  result_df = nlp_pipeline(df)
108
 
109