当前位置: 首页>>代码示例>>Python>>正文


Python Math.log10方法代码示例

本文整理汇总了Python中java.lang.Math.log10方法的典型用法代码示例。如果您正苦于以下问题:Python Math.log10方法的具体用法?Python Math.log10怎么用?Python Math.log10使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.Math的用法示例。


在下文中一共展示了Math.log10方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: analyseTable

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import log10 [as 别名]
def analyseTable(tablename, trace=0):
    tableDict = {}
    tableDict["tableName"]=tablename
    columns = execute("describe "+tablename)
    tableDict["tableColumnCount"]=len(columns)
    count = eval(execute("select count(*) from "+tablename)[0][0])
    tableDict["tableRowCount"]=count
    tableDict["tableColumns"]={}
    for column in columns:
        columnDict = {}
        columnDict["columnName"] = column[0]
        columnType = "data"
        columnQualifier = ""
        if trace:
            print column[0]
        query = ("select count(distinct "+column[0]+") from "+tablename)
        distinctCount = eval(execute(query)[0][0])
            
        #print distinctCount
        if distinctCount == count:
            if trace:
                print "Each value is distinct"
            columnType = "unique"
            columnDict["information"]=log2up(distinctCount)
        else:
            distincts = execute("select distinct "+column[0]+", count(*) from "+tablename+" group by "+column[0])
            #print distincts
            reverseCounts, examples = analyseDistinctValues(distincts)
            #print reverseCounts
            celltotal = 0
            cells = 0
            for reverseCount in reverseCounts.keys():
                if not(reverseCounts[reverseCount]==1 and examples[reverseCount]==None):
                    cells+=reverseCounts[reverseCount]
                    celltotal += Math.log10(reverseCount)* reverseCounts[reverseCount]
        
            if cells>0:
                cellavg = 10**(celltotal / cells)
        
                if trace:
                    print "avg occurrence", cellavg
            
        
            standouts={}
            for reverseCount in reverseCounts.keys():
                #print reverseCount
                if reverseCounts[reverseCount]==1 and examples[reverseCount]==None:
                    standouts["Nulls"]=reverseCount
                    if trace:
                        print "Null occurs", reverseCount, "times."
                if reverseCount == count:
                    columnType = "unused"
                elif reverseCount >= (0.9 * count):
                    columnQualifier += "sparselyUsed "
                else:
                    if trace:
                        print "There is/are",reverseCounts[reverseCount], "value(s) that occurs", reverseCount, "times. eg",examples[reverseCount]
                occurrence = {}
                occurrence["repeatCount"]=reverseCount
                occurrence["valueCount"]=reverseCounts[reverseCount]
                occurrence["example"]=examples[reverseCount]
                if reverseCount > 100 * cellavg:
                    if trace:
                        print "*** HIGH OCCURRENCE"
                    standouts["highFrequency-"+str(reverseCount)]=occurrence
                    if columnQualifier.find("unbalanced")<0:
                        columnQualifier += "unbalanced "
                elif reverseCount <  cellavg / 50:
                    if trace:
                        print "*** LOW OCCURRENCE"
                    standouts["lowFrequency-"+str(reverseCount)]=occurrence
                    if columnQualifier.find("unbalanced")<0:
                        columnQualifier += "unbalanced "
                  
            columnDict["standouts"]=standouts
              
            if columnType == "data":
                if distinctCount == 1:
                    columnType = "constant"
                elif distinctCount < 10:
                    columnType = "smallCategorisation"
                elif distinctCount < 40:
                    columnType = "categorisation"
                elif distinctCount > count/2:
                    columnType = "key"
                      
            #print "information content:",collapse(condense(sorted(prepare(reverseCounts))))
            columnDict["information"]=collapse(condense(sorted(prepare(reverseCounts))))[0][2]
                      
        if trace:
            print column[0],"looks like",columnQualifier+columnType
        columnDict["looksLike"]=columnType
        columnDict["qualifier"]=columnQualifier
        if trace:
            print 
        tableDict["tableColumns"][column[0]]=columnDict
    return tableDict
开发者ID:andrewcaelliott,项目名称:acedata,代码行数:99,代码来源:data1.py


注:本文中的java.lang.Math.log10方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。