本文整理汇总了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)