Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
338 views
in Technique[技术] by (71.8m points)

How to calculating percentage on sqlite table

I created a table in sqlite. There are ID, Name, Group, Salary columns. And I was told to add a Bonus column, which I have created. In the bonus column, I have to fill the value of the bonus received by 5% of my salary. I'm stuck here, do you know what query I should use?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You could use pandas is good for reading charts

import pandas as pd

def percent(expression):
    if "%" in expression:
        expression = expression.replace("%","/100")
    return eval(expression)

data = pd.read_csv("filename.csv") 
Value = DataFrame.get_value('the index you want to take from', 'the column name', 'the role name', takeable = true)
Answer = percent("Value*5%")


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...