Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 指定Django DecimalField的有效位数_Python_Django_Postgresql - Fatal编程技术网

Python 指定Django DecimalField的有效位数

Python 指定Django DecimalField的有效位数,python,django,postgresql,Python,Django,Postgresql,Django很清楚,基于Python,十进制字段是一个固定精度的十进制数 如果我有12位有效数字的预先存在的数据,我应该如何对此进行充分建模 例如,下面是一个感兴趣的数据示例: shape_leng | shape_area --------------+-------------- 1530.79895768 | 90408.0667370 1936.60719682 | 182948.426626 232.229916910 | 1961.07387818 298.135367400

Django很清楚,基于Python,十进制字段是一个固定精度的十进制数

如果我有12位有效数字的预先存在的数据,我应该如何对此进行充分建模

例如,下面是一个感兴趣的数据示例:

shape_leng    |  shape_area
--------------+--------------
1530.79895768 | 90408.0667370
1936.60719682 | 182948.426626
232.229916910 | 1961.07387818
298.135367400 | 1206.32979471
7492.74283181 | 351026.396309
2284.47421526 | 240449.624361
1190.40843206 | 85766.7212220
579.035061001 | 17493.1577514
2532.91949894 | 343607.358136
3332.89318722 | 709775.074538
3259.11802943 | 378845.260875
3482.11473711 | 727006.254061
有些条目只有6位小数,而其他条目则多达9或10位。由于这只是数据集中的一个样本,可以想象,有些数据集可能具有更大的值范围。无论如何,每个条目都有12位数字和一个小数点

在我的第一个过程中,我将模型设置为:

shape_leng = models.DecimalField(max_digits=25, decimal_places=12, blank=True, null=True)
shape_area = models.DecimalField(max_digits=25, decimal_places=12, blank=True, null=True)
缺点是我现在允许最多25位,尽管我知道真正的最大数字只能是12或13

有没有更好的方法来表示这一点?某种可变精度的数字类型,只需要一个科学的风格,有效数字类型的精度