This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 通过地理位置过滤出特定高校的学生 | |
-- 查询20140301前的地理信息数据,请将log.mobile_data_location替换为log.mobile_data_location_oldtb | |
-- v0.1北京大学20131101上报的终端 | |
SELECT DISTINCT | |
uuid | |
FROM | |
log.mobile_data_location | |
WHERE | |
dt = '20131101' | |
AND marslat > 39.98714 AND marslat < 39.996889 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = sc.parallelize(Seq(("A", 2), ("A", 4), ("B", 2), ("Z", 0), ("B", 10))) | |
// data: org.apache.spark.rdd.RDD[(java.lang.String, Int)] = ParallelCollectionRDD[31] at parallelize at <console>:12 | |
val avgValue = data.mapValues((_, 1) | |
.reduceByKey((x, y) => (x._1 + y._1, x._2 + y._2)) | |
.mapValues{ case (sum, count) => (1.0 * sum) / count } | |
.collectAsMap() | |
// avgValue: scala.collection.Map[java.lang.String,Double] = Map(Z -> 0.0, B -> 6.0, A -> 3.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <math.h> | |
const double x_pi = 3.14159265358979324 * 3000.0 / 180.0; | |
void bd_encrypt(double gg_lat, double gg_lon, double &bd_lat, double &bd_lon) | |
{ | |
double x = gg_lon, y = gg_lat; | |
double z = sqrt(x * x + y * y) + 0.00002 * sin(y * x_pi); | |
double theta = atan2(y, x) + 0.000003 * cos(x * x_pi); | |
bd_lon = z * cos(theta) + 0.0065; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
春运发券数据统计 | |
""" | |
def filter_cond(): | |
fcoupon = open(r'/Users/ytjia/Downloads/20w发券用户') | |
fconsume = open(r'/Users/ytjia/Downloads/period_consume') | |
fcouponbuy = open(r'/Users/ytjia/Downloads/consumed_coupon', 'w') | |
fnormalbuy = open(r'/Users/ytjia/Downloads/consumed_normal', 'w') |