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


Python SQLContext.uncacheTable方法代码示例

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


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

示例1: distinct

# 需要导入模块: from pyspark.sql import SQLContext [as 别名]
# 或者: from pyspark.sql.SQLContext import uncacheTable [as 别名]
#Extract all classes. Here, distinct crime types 
CrimeTypes = sqlContext.sql("SELECT distinct(crimetype) AS crimetypes FROM chicagocrimedata order by crimetypes").collect()
allCrimeTypes = list()
for index in range(len(CrimeTypes)):
    allCrimeTypes.append(CrimeTypes[index][0])
    
  
    
#Extracting statistics of crimes top 10 
crimeCounts=sqlContext.sql("SELECT crimetype,count(*) as crimeCount FROM chicagocrimedata GROUP BY crimetype order by crimeCount desc LIMIT 10").collect()
countByCrimeType = {}
for index in range(len(crimeCounts)):
    countByCrimeType[crimeCounts[index].crimetype] = crimeCounts[index].crimeCount

#print countByCrimeType.items()
sqlContext.uncacheTable("chicagocrimedata")         
timeMatrix.registerTempTable("TimeMatrix")


test = dict.fromkeys(list(countByCrimeType),0)
for crime in countByCrimeType:
    test[crime] = sqlContext.sql("SELECT timeslot,countPerTime FROM TimeMatrix WHERE crimetype = '"+crime+"' order by timeslot").collect()


#Displaying graph 
print dict(test)
notes = list()
for crime in countByCrimeType:
    if (len(test[crime])==8):
        plt.plot(range(1,9),[test[crime][x].countPerTime for x in range(len(test[crime]))])
        notes.append(crime)
开发者ID:MySelfSivaKrishna,项目名称:Chicago_Crime_Prediction_Apache_Spark,代码行数:33,代码来源:NaiveGraphs.py


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