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


Python DataArray.sort方法代码示例

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


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

示例1: update_houseids

# 需要导入模块: from openamos.core.data_array import DataArray [as 别名]
# 或者: from openamos.core.data_array.DataArray import sort [as 别名]
    def update_houseids(self, hhldSyn, persSyn, hhldVars, persVars, highestHid):

	hhldSynDataObj = DataArray(hhldSyn, hhldVars)
        persSynDataObj = DataArray(persSyn, persVars)

	
	maxFreqCol = amax(hhldSynDataObj.columns(['frequency']).data)
	powFreqCol = floor(log(maxFreqCol, 10)) + 1

	coefficients = {'frequency':1, 'hhid':10**powFreqCol}

	newHid = hhldSynDataObj.calculate_equation(coefficients)
	hhldSynDataObj.setcolumn('hhid', newHid)

	newHid = persSynDataObj.calculate_equation(coefficients)
	persSynDataObj.setcolumn('hhid', newHid)


	hhldSynDataObj.sort([self.idSpec.hidName])
	persSynDataObj.sort([self.idSpec.hidName, self.idSpec.pidName])

	hidIndex_popgenH = hhldVars.index('hhid')
	hidIndex_popgenP = persVars.index('hhid')

        self.create_indices(persSynDataObj)

	hhldSyn = hhldSynDataObj.data
	persSyn = persSynDataObj.data

	row = 0
        for hhldIndex in self.hhldIndicesOfPersons:

            firstPersonRec = hhldIndex[1]
            lastPersonRec = hhldIndex[2]

	    #print hhldIndex[0], highestHid + 1, firstPersonRec, lastPersonRec

	    hhldSyn[row,hidIndex_popgenH] = highestHid + 1
	    persSyn[firstPersonRec:lastPersonRec,hidIndex_popgenP] = highestHid + 1

	    highestHid += 1
	    row += 1

	return hhldSyn, persSyn
开发者ID:foss-transportationmodeling,项目名称:simtravel,代码行数:46,代码来源:immigration.py

示例2: select_join

# 需要导入模块: from openamos.core.data_array import DataArray [as 别名]
# 或者: from openamos.core.data_array.DataArray import sort [as 别名]

#.........这里部分代码省略.........

                    spatialJoinStr = (""" join (select %s, %s """\
                                          """from %s as %s """\
                                          """inner join %s as %s """\
                                          """on ( %s and %s) group by"""\
                                          """ %s) """\
                                          """as sptime on (%s)"""
                                      % (spGrpNewNameStr, timeColsStr,
                                         stTable, 'st',
                                         enTable, 'en',
                                         spInnerJoinCondition, analysisPeriodStr,
                                         spGrpStr,
                                         spJoinCondition))
                    #print 'SPATIAL JOIN'
                    #print spatialJoinStr
                    # left join for start location

                    stLocJoinStr = (""" left join %s %s on """\
                                        """(%s) """
                                    %(stTable, 'stl', stLocJoinCondition))


                    enLocJoinStr = (""" left join %s %s on """\
                                        """(%s) """
                                    %(enTable, 'enl', enLocJoinCondition))


                    joinStrList.append(spatialJoinStr)
                    joinStrList.append(stLocJoinStr)
                    joinStrList.append(enLocJoinStr)

                    cols_list += timeColsNewNames


                    for i in timeColsNewNames:
                        final_list.append('sptime.%s' %(i))
                    # Only one time-space prism can be retrieved within a component
                    # there cannot be two TSP's in the same component
                    break






        # Generating the col list
        colStr = ''
        for i in final_list:
            colStr = colStr + '%s,' %(i)
        colStr = colStr[:-1]

        # Build the SQL string
        allJoinStr = ''
        for i in joinStrList:
            allJoinStr = allJoinStr + '%s' %i


        sql_string = 'select %s from %s %s' %(colStr, mainTable, allJoinStr)
        print 'SQL string for query - ', sql_string



        #convert all the table names to upper case
        for each in table_list:
            tabs_list.append(each.upper())
        #print 'tabs_list is %s'%tabs_list

        #separate all the columns from the lists
        new_keys = db_dict.keys()
        for i in new_keys:
            cols_list = cols_list + db_dict[i]
        #print 'cols_list is %s'%cols_list

        try:
            sample_str = ''
            ctr = 0
            for i in tabs_list:
                if ctr==0:
                    sample_str = i
                    ctr = ctr + 1
                else:
                    sample_str = sample_str + ', ' + i
                query = self.dbcon_obj.session.query((sample_str))

            #print 'sample_str is %s'%sample_str

            result = query.from_statement(sql_string).values(*cols_list)

            resultArray = self.createResultArray(result)

            # Returns the query as a DataArray object
            data = DataArray(resultArray, cols_list)

            data.sort(primCols)
            self.dbcon_obj.close_sessionInstance()

            return data
        except Exception, e:
            print e
            print 'Error retrieving the information. Query failed.'
开发者ID:foss-transportationmodeling,项目名称:simtravel,代码行数:104,代码来源:query_browser.py


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