There is no threshold to use GPT+Cloud Studio to assist programming to complete Excel automatic salary settlement

insert image description here

foreword

chatgptBrief introduction:
ChatGPTIt is a GPTnatural language processing model based on , which is specially used to generate conversational text. Released by OpenAI in 2021, it is trained on an extensive dialogue dataset and aims to provide a more interactive and adaptable dialogue experience.

Unlike traditional question answering systems, ChatGPTit is designed to handle continuous conversations rather than just individual questions and answers. It can take in the context of a conversation and respond with a better understanding of the context of the conversation, resulting in a more coherent, personalized answer.
In the field of developers, GPTauxiliary work has also been excavated one by one-assistant programming, code search, unit testing, integration testing and so on.
With GPTthe continuous development of technology and the continuous popularization of applications, we can use it gptto help us complete simple small projects.

1. Cloud Studio product introduction

Cloud Studiois a browser-based integrated development environment ( IDE), which provides developers with an always-on cloud workstation. Users Cloud Studiodon't need to install it when using it, and they can program online anytime, anywhere by opening a browser, which is really not too convenient.
insert image description here
Cloud StudioAs online IDE, it includes code highlighting, auto-completion, Git integration, terminal and other basic functions of the IDE, and supports real-time debugging and plug-ins Extensions, etc., can help developers quickly complete the development, compilation and deployment of various applications. The effect is quite good.

insert image description here

Cloud StudioAll new and old users will be given 3000free minutes of work space per month.

1.1 Register Cloud Studio

Cloud Studio official website

First enter Cloud Studiothe official website
insert image description here

After the registration is complete, you can log in through WeChat scanning code verification.

insert image description here

2. Project experiment

2.1 Choose the right development environment

Here we use to write pythoncode.
insert image description here

In the automatically created environment:
insert image description here

2.2 Introduction to Experimental Projects

In the experimental Excelform, the amount of attendance deduction, personal tax deduction, and real salary are currently blank. The final generated data needs to fill in the data in the above three columns according to the following rules.

1. Accounting method for the number of late arrivals:

No deduction within 3 times,
100 will be deducted for each additional time for more than 3 times (that is, starting from the 4th time)

2. Accounting method for personal tax deduction:

tax deduction = base salary - Deduction of five insurances and one housing fund-Amount of attendance deduction

Then calculate as follows:

The individual tax threshold is not considered.
If the income does not exceed 3,000 yuan, a tax rate of 3% is paid.
3,000 yuan -12,000 yuan is taxed at a rate of 10%.
If the amount exceeds 12,000 yuan but not more than 25,000 yuan, the tax rate is 20%.
25,000 yuan-35,000 yuan is calculated at a tax rate of 25%.
35,000-55,000 yuan is calculated at a tax rate of 30%.
55,000 yuan-80,000 yuan is calculated at a tax rate of 35%.

3. Fill the calculated results into the salary.xlsx table

The pre-examination deduction amount is filled in the original document.
The personal tax deduction is filled in the original file.
The paid salary is filled in the original file.

4. Create a new file to output the data in the table in the Cloud Studio terminal

2.3 Experimental steps

  1. First upload the experimental files that need to be processed Excel, and upload them to the root directory of the environment Cloud Studio.Python

insert image description here
After uploading successfully:
insert image description here

Create pyfile:

insert image description here
insert image description here

  1. Use GPTauxiliary programming:
    insert image description here

Paste the code into Cloud Studio, click "run" button.

insert image description here

After pasting and running, I found that there is no library in the default environment pandas, OK! Let's install it. If the following appears Successfully, the installation is successful

insert image description here

Install pandasthe library:

pip install pandas

insert image description here

Next, run it again demo.py, and still report an error, because pandassome functions of the library depend on openpyxl, and the default environment is not installed, so we continue to install:

install openpyxl:

pip install openpyxl

After the installation is successful, let's run it againdemo.py

Finally, the real salary can be calculated, but the tax deduction bonus has not been calculated, because the demand has not been raised yet.
insert image description here

Continue GPTthe dialogue with the requester.
insert image description here

import pandas as pd
#读取Excel表格
df = pd.read_excel( 'salary.xlsx', sheet_name= "Sheet1")
#计算考勤扣除金额
late_counts = df['迟到次数']
df['考勤扣除金额']= late_counts.apply(lambda x: max((x-3)*100,0))
#计算个税扣除
taxable_income = df['工资基数']- df['五险一金扣除']- df['考勤扣除金额']
df['个税扣除']= taxable_income . apply(lambda x:
min(x*0.03,90) if x <=3000 else
min(x*0.1,210) if 3000<x<=12000 else
min(x*0.2,1410) if 12000<x<=25000 else
min(x*0.25,2660) if 25000<x<=35000 else
min(x*0.3,4410) if 35000<x<=55000 else
min(x*0.35,7160) if 55000<x<=80000 else
x*0.45)
#计算实发工资
df['实发工资']= df['工资基数']- df['五险一金扣除']- df['考勤扣除金额']-df['个税扣除']
#打印结果
print(df)

#计算实发工资
df['实发工资']= df['工资基数']- df['五险一金扣除']- df['考勤扣除金额']-df['个税扣除']
#写入Excel
writer = pd.ExcelWriter('salary_output.xlsx')
df.to_excel(writer,'Sheet1', index=False)
writer.close()
print('结果已成功写入Excel!')

print(df)

It can be seen that the result was successfully output, and it did not fully comply with my regulations. After changing the original file, it output a new file. But Excelafter verifying by printing and downloading files, there is basically no problem. Of course, GPTwe can’t rely on our answers. On the one hand, GPTwe can’t handle complex requirements, and can only help us solve simple examples. On the other hand, the answers often do not meet the requirements, which requires the user to have the ability to discriminate, and To have the ability to solve and improve, you need to be hardworking, and the most important thing is to improve yourself!

Finally, the small experiment is over here, and Cloud Studiothe evaluation is over. I personally feel that it is a good online programming platform. Interested friends can try it.
insert image description here

Guess you like

Origin blog.csdn.net/qq_67276605/article/details/131975404