鍍金池/ 問答/ 數(shù)據(jù)分析&挖掘問答
眼雜 回答

if(this.moduleList[1]&&this.moduleList[1]. childModuleList)

背叛者 回答

用 pillow 模塊把各式圖片轉(zhuǎn)換成像素集,然后轉(zhuǎn)成 numpy 數(shù)組,最后保存到文件。

請參考下面的代碼

# -*- coding: utf-8 -*-
from PIL import Image
import numpy as np


def images_to_array(image_files, array_file):
    """ 將多個圖像文件保存成 numpy 數(shù)組,并存儲到 .npy 文件。
    """
    data = []
    for filename in image_files:
        data.append(np.array(Image.open(filename)))
    np.save(array_file, data)


def load_images(array_file):
    """ 從 .npy 文件讀取所有圖像數(shù)組。
    """
    return np.load(array_file)


images_to_array(['1.png', '2.png'], '1.npy')
load_images('1.npy')

參考資料

  1. https://pillow.readthedocs.io...
  2. https://docs.scipy.org/doc/nu...
荒城 回答

碰到了一樣的問題,同樣求解答

乖乖瀦 回答

如果確定數(shù)組里只有payment_typeplace_rental兩個key的話,那么完全可以把payment_type的值當(dāng)下標(biāo),count_place_rental當(dāng)做值

$new_arr = [];
foreach ($arr['info'] as $key => $value) {
    if (!isset($new_arr[$value['payment_type']]) || empty($new_arr[$value['payment_type']])) {
        $new_arr[$value['payment_type']] = $value['place_rental'];
    } else {
        $new_arr[$value['payment_type']] += $value['place_rental'];
    }
}
var_dump($new_arr);
葬愛 回答
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void demo(char *list[])
{
        int i;
        char *name;
        for (i=0; i< 10; i++) {
                name = (char *)malloc(sizeof(char)*6);//這里的6需根據(jù)文本長度進行改變
                sprintf(name, "root%d", i);
                list[i] = name;
                printf("%d=>%s\n", i, list[i]);
        }
}
void main()
{
        char **list;
        int i, len=10;

        //可變數(shù)組
        list = (char **)malloc(sizeof(char *)*len);

        demo(list);

        printf("\n");
        for(i=0; i < len; i++) {
            printf("%d=>%s\n", i, list[i]);
        }
}
空痕 回答

最后一行改成:
map(if_novel,movies['keywords'])

尐潴豬 回答

phantomjs 已經(jīng)不推薦使用了,pyspider v0.3.9 已經(jīng)支持 splash ,建議使用 splash 渲染 js。
Enabled by fetch argument --splash-endpoint=http://splash:8050/execute
調(diào)用的時候使用 fetch_type='splash'

不舍棄 回答

cookie一樣是只是session一樣,session里面的內(nèi)容可以不同

你的網(wǎng)站我看了一下PHP_SESSIONID是一樣的,所以COOKIE不變。

但是$_SESSION的內(nèi)容可以改變。所以有了你說的情況

尐潴豬 回答

xpath該這么寫:"http://span[@class='price J-p-5056201']/text()|//span[@class='price J-p-p-5056201']/text()"

笨小蛋 回答

請?zhí)峁┮粋€可重復(fù)的例子

誮惜顏 回答

現(xiàn)在你是“客戶端”,你要在www.baidu.com這臺服務(wù)器上打印$_SERVER['HTTP_REFERER']才會得到你作為客戶端偽造的referer

伴謊 回答
pd.concat(frames, axis=1, join_axes=[A.index])

而不是 'A'.index, 加單引號表示其為字符串了。

北城荒 回答

map的返回值是一個數(shù)組,這個問題用forEach比較合適

let newArr = [];
arr01.forEach(a1 => {
    arr02.forEach(a2 => {
        newArr.push({
            account: a1.account,
            city: a2.city
        });
    });
});
有點壞 回答

Greenplum 默認禁用 Index Scan, 打開試試。

set enable_indexscan = on;

對于小數(shù)據(jù)量、簡單查詢,Greenplum 的分布式架構(gòu)比單機的 Postgresql 慢是正常的。分布式事務(wù)、查詢計劃下發(fā)等都會帶來不小的固定時間開銷。

氕氘氚 回答

可以直接在selectNav這個方法中判斷索引為2的不做處理就可以了

孤客 回答

數(shù)據(jù)溢出,將matrix類型轉(zhuǎn)為 float然后計算梯度

萌小萌 回答

php 版本問題 5.4 以上才支持短數(shù)組寫法

php 5.4

風(fēng)畔 回答
import pandas as pd
threedays = ['2018/3/9', '2018/3/10', '2018/3/11']
df = pd.read_csv('test.csv')
df = df[df['data_date'].isin(threedays)].groupby(['data_date', 'product_id']).sum().reset_index(drop=False) # 過濾最近三天并求和

def f(df):
    if len(df) == 3:
        # 三天都有數(shù)
        r = [df['uv'][df['data_date'] == threedays[i]].values[0] for i in range(3)]
        return (r[2] - r[1] < 100) and r[2] > r[1] and (r[1] - r[0] < 100) and r[1] > r[0] #增長大于0小于100
    else:
        return False

r = df.groupby('product_id').apply(f)
print(list(r[r==True].index))

條件2類比,把f改一下就ok了

尐飯團 回答

fillNumberInOneArray 將數(shù)字 m 填入到 第 n 個小宮格中,為什么要隨機選一個位置放呢?后期快放滿的時候,沖突的概率越來越大,根本不收斂的呀。你都能 judgeElse 了,為什么不能在生成 random 坐標(biāo)之前就排除一下已經(jīng)放了數(shù)字的格子呢?這一步浪費的效率不計其數(shù),甚至導(dǎo)致了算法有極大可能無法停止。9個格子有一個空位,用random去撞這個空位置,那有 8/9 的概率撞不到,一直死循環(huán)。

已經(jīng)被占的格子提前排除,這是其一。其二,假設(shè)小9宮格都剩下3個格子,需要放 7 了對吧,隨機一下,得到一個空格子,檢查了一下橫豎,發(fā)現(xiàn)不能放,接下來你需要標(biāo)記這個格子不可用,否則下次再 random 還有 1/3 的概率打中這個不可用的格子,導(dǎo)致算法不收斂。犯過的錯,為什么下次還要繼續(xù)犯?下次你就該排除掉它,在剩下的選項里挑,否則這次試錯就沒有意義啦,那這就不是算法,完全就是在碰運氣。

function calculateCoordinate(position,n) 也可以精簡一下,沒必要那么多 switch-case:

function calculateCoordinate(position, n) {
  // 先計算九宮格是幾排幾列的九宮格, 我們把數(shù)獨看成是 3*3 的9個9宮格
  var nx = n % 3;
  var ny = Math.floor(n / 3); 

  var px = position % 3;
  var py = Math.floor(position / 3);
  // 同樣的套路處理小9宮格內(nèi)的坐標(biāo),
  
  // 轉(zhuǎn)換一下坐標(biāo)系
  var returnX = px + nx * 3; 
  var returnY = py + ny * 3;
  return [returnY, returnX];
}