小编Geo*_*ler的帖子

rxjs flatmap缺失

我尝试链接多个rx.js可观察量并传递数据.Flatmap应该是拟合运算符但是导入

import { Observable } from 'rxjs/Observable';
Run Code Online (Sandbox Code Playgroud)

找不到:

Error TS2339: Property 'flatmap' does not exist on type 'Observable<Coordinates>'
Run Code Online (Sandbox Code Playgroud)

5.0.0-beta.6使用rx.js的版本.

public getCurrentLocationAddress():Observable<String> {
    return Observable.fromPromise(Geolocation.getCurrentPosition())
      .map(location => location.coords)
      .flatmap(coordinates => {
        console.log(coordinates);
        return this.http.request(this.geoCodingServer + "/json?latlng=" + coordinates.latitude + "," + coordinates.longitude)
          .map((res: Response) => {
                       let data = res.json();
                       return data.results[0].formatted_address;
              });
      });
  }
Run Code Online (Sandbox Code Playgroud)

reactive-extensions-js observable rxjs

57
推荐指数
5
解决办法
4万
查看次数

pandas concat生成nan值

我很好奇为什么pandas中两个数据帧的简单连接:

shape: (66441, 1)
dtypes: prediction    int64
dtype: object
isnull().sum(): prediction    0
dtype: int64

shape: (66441, 1)
CUSTOMER_ID    int64
dtype: object
isnull().sum() CUSTOMER_ID    0
dtype: int64
Run Code Online (Sandbox Code Playgroud)

具有相同的形状,两者都没有NaN值

foo = pd.concat([initId, ypred], join='outer', axis=1)
print(foo.shape)
print(foo.isnull().sum())
Run Code Online (Sandbox Code Playgroud)

如果加入,会导致很多NaN值.

(83384, 2)
CUSTOMER_ID    16943
prediction     16943
Run Code Online (Sandbox Code Playgroud)

如何解决此问题并防止引入NaN值?

试图重现它

aaa  = pd.DataFrame([0,1,0,1,0,0], columns=['prediction'])
print(aaa)
bbb  = pd.DataFrame([0,0,1,0,1,1], columns=['groundTruth'])
print(bbb)
pd.concat([aaa, bbb], axis=1)
Run Code Online (Sandbox Code Playgroud)

失败,例如工作得很好,因为没有引入NaN值.

python concatenation nan dataframe pandas

35
推荐指数
2
解决办法
3万
查看次数

tensorflow Mac OS gpu支持

根据

https://www.tensorflow.org/install/install_mac注意:从版本1.2开始,TensorFlow不再在Mac OS X上提供GPU支持.不再提供对OS X的GPU支持.

但是,我想通过thunderbolt 3来运行像akitio节点这样的e-gpu设置.

要使此设置生效,需要执行哪些步骤?到目前为止,我知道

是必要的.还有什么需要让CUDA/tensorflow工作?

macos tensorflow tensorflow-gpu

27
推荐指数
3
解决办法
4万
查看次数

Spark 2.0 Dataset vs DataFrame

从spark 2.0.1开始我有一些问题.我阅读了很多文档,但到目前为止找不到足够的答案:

  • 有什么区别
    • df.select("foo")
    • df.select($"foo")
  • 我能正确理解吗
    • myDataSet.map(foo.someVal)是类型安全的,不会转换为RDD但保留在DataSet表示/没有额外的开销(2.0.0的性能明智)
  • 所有其他命令,例如select,..只是语法糖.它们不是类型安全的,可以使用地图代替.如果df.select("foo")没有地图声明,我怎么能输入?
    • 为什么我应该使用UDF/UADF而不是地图(假设地图保留在数据集表示中)?

scala apache-spark apache-spark-sql apache-spark-dataset apache-spark-2.0

23
推荐指数
1
解决办法
4687
查看次数

熊猫读了嵌套的json

我很好奇如何使用pandas来读取以下结构的嵌套json:

{
    "number": "",
    "date": "01.10.2016",
    "name": "R 3932",
    "locations": [
        {
            "depTimeDiffMin": "0",
            "name": "Spital am Pyhrn Bahnhof",
            "arrTime": "",
            "depTime": "06:32",
            "platform": "2",
            "stationIdx": "0",
            "arrTimeDiffMin": "",
            "track": "R 3932"
        },
        {
            "depTimeDiffMin": "0",
            "name": "Windischgarsten Bahnhof",
            "arrTime": "06:37",
            "depTime": "06:40",
            "platform": "2",
            "stationIdx": "1",
            "arrTimeDiffMin": "1",
            "track": ""
        },
        {
            "depTimeDiffMin": "",
            "name": "Linz/Donau Hbf",
            "arrTime": "08:24",
            "depTime": "",
            "platform": "1A-B",
            "stationIdx": "22",
            "arrTimeDiffMin": "1",
            "track": ""
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

这里将数组保持为json.我宁愿把它扩展成列.

pd.read_json("/myJson.json", orient='records')
Run Code Online (Sandbox Code Playgroud)

编辑

谢谢你的第一个答案.我应该改进我的问题:数组中嵌套属性的扁平化不是强制性的.只需[A,B,C]连接df.locations ['name']即可.

我的文件包含多个JSON对象(每行1个)我想保留数字,日期,名称和位置列.但是,我需要加入这些地点. …

python parsing json pandas

22
推荐指数
2
解决办法
2万
查看次数

火花火车测试分裂

我很好奇,如果在最新的2.0.1版本中有类似于sklearn的 http://scikit-learn.org/stable/modules/generated/sklearn.model_selection.StratifiedShuffleSplit.html for apache-spark.

到目前为止,我只能找到https://spark.apache.org/docs/latest/mllib-statistics.html#stratified-sampling,它似乎不适合将严重不平衡的数据集拆分为火车/测试样本.

apache-spark apache-spark-mllib train-test-split

13
推荐指数
3
解决办法
9415
查看次数

处理标签编码的未知值

如何在sk-learn中处理标签编码的未知值?只有在检测到新标签时,标签编码器才会爆炸.

我想要的是通过one-hot -encoder 对分类变量进行编码.但是,sk-learn不支持字符串.所以我在每列上都使用了标签编码器.

我的问题是,在我的交叉验证步骤中,管道中出现了未知标签.基本的单热编码器可以选择忽略这种情况.apriori pandas.getDummies /cat.codes是不够的,因为管道应该使用可能包含未知标签的真实,新鲜的传入数据.

是否有可能CountVectorizer为此目的使用?

python pandas scikit-learn dummy-variable one-hot-encoding

13
推荐指数
1
解决办法
6718
查看次数

火花访问前n行 - 采取vs限制

我想访问火花数据帧的前100行,并将结果写回CSV文件.

为什么take(100)基本上是即时的,而

df.limit(100)
      .repartition(1)
      .write
      .mode(SaveMode.Overwrite)
      .option("header", true)
      .option("delimiter", ";")
      .csv("myPath")
Run Code Online (Sandbox Code Playgroud)

需要永远.我不想获得每个分区的前100条记录,而只需要获得100条记录.

limit apache-spark apache-spark-sql spark-dataframe

13
推荐指数
2
解决办法
1万
查看次数

Rails依赖哪些选项可能?

我在Rails 4中收到以下错误

依赖选项必须是destroy delete之一

显然https://github.com/rails/rails/issues/3458之前支持其他选项.但是现在有什么可能呢?我找不到任何其他文件

谢谢您的帮助

ruby-on-rails destroy dependent-destroy ruby-on-rails-4

12
推荐指数
1
解决办法
6078
查看次数

火花堆内存配置和钨

我认为通过项目Tungesten的集成,spark会自动使用堆内存.

什么是spark.memory.offheap.size和spark.memory.offheap.enabled?我是否需要手动指定Tungsten的关闭堆内存量?

apache-spark apache-spark-sql spark-dataframe apache-spark-2.0 off-heap

12
推荐指数
1
解决办法
6787
查看次数