首页 \ 问答 \ 在列表中显示mongo中的相应字段(display corresponding fields in mongo in a list)

在列表中显示mongo中的相应字段(display corresponding fields in mongo in a list)

这是我存储的数据:

{ "_id" : ObjectId("57080a7b01351177a4113f63"), "title" : "Data Scientist", "url" : "https://www.Pinterest.com/jobs/732?t=nu6xow", "timestamp" : "2016-04-08 19:46:03", "company" : "Pinterest", "state" : " CA", "todays_date" : "04/08/2016", "city_name" : "San+Francisco", "location" : "San Francisco, CA", "team" : "T0BT323QS", "search_word" : "Data+scientist"}
{ "_id" : ObjectId("57080a7b01351177a4113f64"), "title" : "Director of Analytics / Data Mining", "url" : "http://www.Pinterest.com/careers-position-data-mining-leader", "timestamp" : "2016-04-08 19:46:03", "company" : "Pinterest", "state" : " CA", "todays_date" : "04/08/2016", "city_name" : "San+Francisco", "location" : "Silicon Valley, CA", "team" : "T0BT323QS", "search_word" : "Data+scientist"}
{ "_id" : ObjectId("57080a7d01351177a4113f65"), "title" : "Senior Real World Data Scientist", "url" : "http://www.Pinterest.com/careers/detail/00443369/Senior-Real-World-Data-Scientist?src=JB-12568", "timestamp" : "2016-04-08 19:46:05", "company" : "Pinterest", "state" : " CA", "todays_date" : "04/08/2016", "city_name" : "San+Francisco", "location" : "South San Francisco, CA", "team" : "T0BT323QS", "search_word" : "Data+scientist"}

这是我的查询:

db.Books.aggregate([{$match:{"timestamp":{
       $gte: "2016-04-08 19:46:03", $lt: "2016-04-08 19:46:06"}}}
     ,{ "$group": {
        "_id": "$company",
        "count": { "$sum": 1 },
        "urls": {
            "$addToSet": "$url"
        }
    }},
    { "$sort": { "count": -1 } },
    { "$limit": 10 },
    { "$project": {
        "count": 1,
        "urls": { "$slice": ["$urls",0, 3] }
    }}
])

这是输出:

{ 
    "_id" : "Pinterest", 
    "urls" : [ 
        "https://www.Pinterest.com/jobs/732?t=nu6xow",
        "http://www.Pinterest.com/careers-position-data-mining-leader",
        "http://www.Pinterest.com/careers/detail/00443369/Senior-Real-World-Data-Scientist?src=JB-12568" 
    ] 
}

但是,与“url”一起,我希望它显示相应的“标题”和“位置”字段。 像这样的东西:

{ 
    "_id" : "Pinterest", 
    "urls" : [ 
        [
            "https://www.Pinterest.com/jobs/732?t=nu6xow",
            "Data Scientist","San Francisco, CA"
        ],[
            "http://www.Pinterest.com/careers-position-data-mining-leader",
            "Director of Analytics / Data Mining","Silicon Valley, CA"
        ],[
            "http://www.Pinterest.com/careers/detail/00443369/Senior-Real-World-Data-Scientist?src=JB-12568",
            "Senior Real World Data Scientist",
            "South San Francisco, CA"
        ]
]}

This is my stored data:

{ "_id" : ObjectId("57080a7b01351177a4113f63"), "title" : "Data Scientist", "url" : "https://www.Pinterest.com/jobs/732?t=nu6xow", "timestamp" : "2016-04-08 19:46:03", "company" : "Pinterest", "state" : " CA", "todays_date" : "04/08/2016", "city_name" : "San+Francisco", "location" : "San Francisco, CA", "team" : "T0BT323QS", "search_word" : "Data+scientist"}
{ "_id" : ObjectId("57080a7b01351177a4113f64"), "title" : "Director of Analytics / Data Mining", "url" : "http://www.Pinterest.com/careers-position-data-mining-leader", "timestamp" : "2016-04-08 19:46:03", "company" : "Pinterest", "state" : " CA", "todays_date" : "04/08/2016", "city_name" : "San+Francisco", "location" : "Silicon Valley, CA", "team" : "T0BT323QS", "search_word" : "Data+scientist"}
{ "_id" : ObjectId("57080a7d01351177a4113f65"), "title" : "Senior Real World Data Scientist", "url" : "http://www.Pinterest.com/careers/detail/00443369/Senior-Real-World-Data-Scientist?src=JB-12568", "timestamp" : "2016-04-08 19:46:05", "company" : "Pinterest", "state" : " CA", "todays_date" : "04/08/2016", "city_name" : "San+Francisco", "location" : "South San Francisco, CA", "team" : "T0BT323QS", "search_word" : "Data+scientist"}

This is my query:

db.Books.aggregate([{$match:{"timestamp":{
       $gte: "2016-04-08 19:46:03", $lt: "2016-04-08 19:46:06"}}}
     ,{ "$group": {
        "_id": "$company",
        "count": { "$sum": 1 },
        "urls": {
            "$addToSet": "$url"
        }
    }},
    { "$sort": { "count": -1 } },
    { "$limit": 10 },
    { "$project": {
        "count": 1,
        "urls": { "$slice": ["$urls",0, 3] }
    }}
])

This is the output:

{ 
    "_id" : "Pinterest", 
    "urls" : [ 
        "https://www.Pinterest.com/jobs/732?t=nu6xow",
        "http://www.Pinterest.com/careers-position-data-mining-leader",
        "http://www.Pinterest.com/careers/detail/00443369/Senior-Real-World-Data-Scientist?src=JB-12568" 
    ] 
}

However, alongwith "url" I want it to display corresponding "title" and "location" field. Something like this:

{ 
    "_id" : "Pinterest", 
    "urls" : [ 
        [
            "https://www.Pinterest.com/jobs/732?t=nu6xow",
            "Data Scientist","San Francisco, CA"
        ],[
            "http://www.Pinterest.com/careers-position-data-mining-leader",
            "Director of Analytics / Data Mining","Silicon Valley, CA"
        ],[
            "http://www.Pinterest.com/careers/detail/00443369/Senior-Real-World-Data-Scientist?src=JB-12568",
            "Senior Real World Data Scientist",
            "South San Francisco, CA"
        ]
]}

原文:https://stackoverflow.com/questions/36753436
更新时间:2023-03-22 18:03

最满意答案

我不确定你是否可以,但我认为你可能不需要。 您已经拥有以下工具:

  • tf.contrib.framework.is_tensor将为tf.contrib.framework.is_tensor返回True
  • tf.executing_eagerly返回True如果你是,那么急切地执行。

我相信他们应该覆盖99%的需求 - 如果漏掉了这个百分比,我会很好奇听到你的问题。


I am not sure if you can, but I think you probably don't need to. You already have the following tools:

  • tf.contrib.framework.is_tensor that will return True for an EagerTensor
  • tf.executing_eagerly that returns True if you are, well, executing eagerly.

I believe they should cover 99% of your needs -- and I would be curious to hear about your problem if it falls in that percentage left out.

相关问答

更多
  • 因为seq2seq已被移至tf.contrib.legacy_seq2seq 。 您应该将此行更改为: outputs, final_state = tf.contrib.legacy_seq2seq.rnn_decoder(inputs, istate, cell, loop_function=None, scope='rnnlm') Because seq2seq has been moved to tf.contrib.legacy_seq2seq. You should change this l ...
  • 只有在对所有数据集运行“推理”后,才能使用sklearn的confusion_matrix。 这意味着,如果要修改eval_only函数,则应将所有分数累积到某个线程安全容器(列表)中。 然后在所有线程停止后(第113行),您可以运行单一混淆矩阵计算。 另外,如果你想在图表中做到这一点,TensorFlow最近得到了confusion_matrix你可以试试。 也就是说,它只适用于批处理,因此您需要增加批处理以获得任何类型的解析或编写自定义聚合器。 You can utilize sklearn's con ...
  • 您可以从Optimizer类实现自己的优化Optimizer 。 您必须至少实现方法_apply_dense或_apply_sparse 。 使用纯已经可用的tensorflow操作完整实现adamax优化器。 class AdamaxOptimizer(optimizer.Optimizer): .. you can create slot variables implementing slot fucntion def _create_slots(self, var_list): ...
  • 我设法解决了这个问题。 在这个例子中我忘了添加一个参数来优化。 import tensorflow as tf import numpy as np # Test data x_dat = np.arange(1, 13).reshape(4, 3).astype(np.float32) y_dat = np.arange(1, 9).reshape(4, 2).astype(np.float32) # Test data x = tf.placeholder(tf.float32, [None, 3] ...
  • 这听起来像是你的Python环境遇到了问题。 处理这个问题的最简单方法是遵循以下步骤: 按照此处的说明将TensorFlow安装到virtualenv中。 这样就避免了获取root权限的需要,并且可以更轻松地尝试不同版本的TensorFlow。 (它也避免了与其他系统安装的不同库的版本冲突。) 按照本指南中的第5步开始,设置PyDev以使用新的virtualenv。 这涉及到建立一个新的“解释器”,它的库将成为virtualenv中的一组库。 您可能需要重新创建您的Eclipse项目才能使用此解释器。 It ...
  • 在初始化所有变量之前,函数foo()根本没有被调用。 所以它无法初始化foo()中的变量。 我们需要在运行会话之前调用该函数。 import tensorflow as tf def foo(): x=tf.Variable(tf.zeros([1])) y=tf.ones([1]) return x+y with tf.Session() as sess: result=foo() init=tf.global_variables_initializer() ...
  • 我不确定你是否可以,但我认为你可能不需要。 您已经拥有以下工具: tf.contrib.framework.is_tensor将为tf.contrib.framework.is_tensor返回True tf.executing_eagerly返回True如果你是,那么急切地执行。 我相信他们应该覆盖99%的需求 - 如果漏掉了这个百分比,我会很好奇听到你的问题。 I am not sure if you can, but I think you probably don't need to. You al ...
  • 你应该看看tf.select 。 举个例子,你可以这样做: condition = tf.greater(x, 0) res = tf.select(condition, tf.square(x), x + 5) You should take a look at tf.where. For your example, you could do: condition = tf.greater(x, 0) res = tf.where(condition, tf.square(x), x + 5) EDI ...
  • my_model不会在您的代码中调用。 它是一个由Estimator调用的具有2个参数的回调函数:特征和标签。 对于fit()函数,它们实际上是x_train和y_train 。 正如文档所说, “模型函数,具有特征和目标张量或张量,并返回预测和损失张量,例如”(特征,目标) - >(预测,损失)“ 您可以在Estimator的源代码中看到1125行中调用了model_fn: model_fn_results = self._model_fn(features, labels, **kwargs) my_ ...
  • 我有同样的问题,运行以下命令解决了我的问题: ./configure 我使用了所有默认配置。 请查看此问题以获取更多信息。 I had the same issue, running the following command solved the problem for me: ./configure I used all the default configurations. Check this issue for more info.

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。