简体   繁体   English

使用 Flask 对 Pandas 中的给定列数据执行算术运算

[英]Performing arithmetic operations on given columns data in Pandas using Flask

To retrieve database values of the particular row back into the template (webpage) by doing some calculations.通过进行一些计算将特定行的数据库值检索回模板(网页)。 But I don't know how to get particular values from an SQL table and perform calculations.但我不知道如何从 SQL 表中获取特定值并执行计算。

So for this purpose, I tried Flask along with Pandas .因此,为此目的,我尝试了 Flask 和Pandas I stored some data in MySQL tables and was able to retrieve its content back into a Flask template in table format:我在 MySQL 表中存储了一些数据,并且能够以表格式将其内容检索回 Flask 模板:

geo = pd.read_sql_table('rsinputs', engine, columns=['province', 'county', 'depmin', 'inventory', 'geo', 'grades', 'asratio', 'dpbaux', 'deratingai203', 'deratingas', 'becol', 'bfcol', 'bgcol', 'bhcol', 'bicol']) geo = pd.read_sql_table('rsinputs', engine, columns=['province', 'county', 'depmin', 'inventory', 'geo', 'grades', 'asratio', 'dpbaux', 'deratingai203' , '降级', 'becol', 'bfcol', 'bgcol', 'bhcol', 'bicol'])

Yes, the output I got is DB tables, but now how do I perform calculations like some value from province + some value from the inventory?是的,我得到的 output 是 DB 表,但是现在我如何执行计算,比如province的一些值 + 库存的一些值?

Yeh, i solved it by myself..恩。。我自己解决了

bf12 = geo['bfcol'].iloc[2] bf12 = geo['bfcol'].iloc[2]

geob = bf12+bf12 geob = bf12+bf12

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM