鍍金池/ 問答/ 數(shù)據(jù)分析&挖掘問答
挽青絲 回答

你要看一下頁面內(nèi)容是不是動態(tài)加載的,瀏覽器里那是已經(jīng) js 加載過的了。

熊出沒 回答

在showArticle渲染出來的前端頁面ajax $get('/getAllarticle)即可拿到數(shù)據(jù)

六扇門 回答

可用“工程名稱”,“招標(biāo)單位”等這些項(xiàng)目名稱作為前綴,再結(jié)合xpath搞定,相當(dāng)穩(wěn)定的。不論它怎么換位置,只要項(xiàng)目名稱不變,就能準(zhǔn)確提取項(xiàng)目內(nèi)容。

孤影 回答

為提升性能,應(yīng)減少 pandas.DataFrame.apply() 的逐行操作,在本例中可改用 numpy.where() 二元操作符,如下

In [1]: import pandas as pd

In [2]: import numpy as np

In [3]: df1 = pd.DataFrame({'t': [1,2,3], 'user_id': [10,20,30], 'v': [1.1,2.2,3.3]})

In [4]: df1
Out[4]: 
   t  user_id    v
0  1       10  1.1
1  2       20  2.2
2  3       30  3.3

In [5]: df2 = pd.DataFrame({'t': [4,1,2], 'user_id': [40,10,20], 'v': [400,100,200]})

In [6]: df2
Out[6]: 
   t  user_id    v
0  4       40  400
1  1       10  100
2  2       20  200

In [7]: df3 = pd.merge(df1, df2, how='right', on=['t', 'user_id'])

In [8]: df3
Out[8]: 
   t  user_id  v_x  v_y
0  1       10  1.1  100
1  2       20  2.2  200
2  4       40  NaN  400

In [9]: df3['v'] = np.where(np.isnan(df3.v_x), df3.v_y, df3.v_x)

In [10]: df3
Out[10]: 
   t  user_id  v_x  v_y      v
0  1       10  1.1  100    1.1
1  2       20  2.2  200    2.2
2  4       40  NaN  400  400.0

In [11]: del df3['v_x']

In [12]: del df3['v_y']

In [13]: df3
Out[13]: 
   t  user_id      v
0  1       10    1.1
1  2       20    2.2
2  4       40  400.0
司令 回答

rules是Rule的列表,所以你可以放多個(gè)規(guī)則不同的Rule

紓惘 回答

如果你dataframe2的index和dataframe1是一致的
dataframe1.drop(dataframe2.index)

練命 回答

別怪我啰嗦,深深的刺痛你。

data = b'你所拿到的全部數(shù)據(jù)'

也就是說,把你的全部數(shù)據(jù)都納入 b'' 中。如果涉及到換行問題,請自行用 Python 來處理即可。

焚音 回答

public class test {
public static List> source;

public static void main(String[] args) {

source = new ArrayList<>();

List<String> a = new ArrayList<String>();
a.add("黑色");
a.add("白色");
List<String> b = new ArrayList<String>();
b.add("64G");
b.add("128G");
List<String> c = new ArrayList<String>();
c.add("中國聯(lián)通");
c.add("中國移動");
source.add(a);
source.add(b);
source.add(c);
ArrayList<String> result = new ArrayList<>();
recursion(result, source.get(0), 0, "");
System.out.println(result);

}

public static void recursion(List<String> result, List<String> para, int num, String choose) {

for (int i = 0; i < para.size(); i++) {
    if (source.size() == num + 1) {
        result.add(choose + "/" + para.get(i));
    } else {
        recursion(result, source.get(num + 1), num + 1, choose + "/" + para.get(i));
    }
}

}
}

蟲児飛 回答
In the current implementation apply calls func twice on the first column/row to decide whether it can take a fast or slow code path. This can lead to unexpected behavior if func has side-effects, as they will take effect twice for the first column/row.

refer: http://pandas.pydata.org/pand...

囍槑 回答

拷貝對象,而不是引用對象,assign與...一樣都是淺拷貝

let b = a.map(item=>{
    return Object.assign({},item)
})
疚幼 回答

什么破書……那個(gè) choice 沒定義在那里,所以新版本不小心就沒了吧……

>>> from numpy.random import choice
>>> choice(['red', 'green'])
'red'
命多硬 回答

你只是定義了一個(gè)Request, 定義好的Request自己并不去去建立網(wǎng)絡(luò)聯(lián)接并下載, 而是能過scrapy的Downloader和Spider來完成.
參考官方文檔:

一般來說,Request 對象在spiders中被生成并且最終傳遞到 下載器(Downloader),下載器對其進(jìn)行處理并返回一個(gè) Response 對象, Response 對象還會返回到生成request的spider中。

如果想讓他運(yùn)行, 可以定義如下的spider

import scrapy
from scrapy.spiders import CrawlSpider, Rule

url = 'https://doc.scrapy.org/en/latest/intro/tutorial.html'


def ret(response):
    print('start print\n')
    print(response.body)

def errorcb(err):
    print(err+"\n")
    pass



class MySpider(CrawlSpider):
    name="test"
    def start_requests(self):
        return [scrapy.http.Request(url=url, callback=ret, errback=errorcb)]

保存成文件scrapy_cb.py, 然后通過

scrapy runspider scrapy_cb.py 

來運(yùn)行

風(fēng)畔 回答

1、要怎麼讓他以 名稱1, 名稱2, 名稱3.... 排列?
在寫sql語句的時(shí)候,寫上

order by 字段名稱 asc

2、把這個(gè)數(shù)據(jù)丟到某個(gè)全局變數(shù)?
全局變量一般以global關(guān)鍵字來聲明,具體可以參考這里
https://www.cnblogs.com/Striv...

孤島 回答
Caused by: org.apache.http.ProtocolException: Content-Length header already present

你是不是指定 Content-Length 頭了

逗婦乳 回答

第一種 php5.5或更高版本

$array       = json_decode('[{"id":1,"name":"張三1"},{"id":2,"name":"張三2"},{"id":3,"name":"張三3"},{"id":4,"name":"張三4"},{"id":5,"name":"張三5"},{"id":6,"name":"張三6"},{"id":7,"name":"張三7"}]');
$arrayWithId = array_column($array, null, 'id');
$result      = $arrayWithId[3];
print_r($result);

第二種

你這是json數(shù)組,如果是php需要使用json_decode() 轉(zhuǎn)換為php數(shù)組,然后for循環(huán)

第三種

如是是js處理,3樓說的對

尤禮 回答

對樹遍歷,重新生成數(shù)組,前端做這工作,挺耗性能的,尤其數(shù)據(jù)量龐大的時(shí)候,可能會卡死,一般我們都讓后端處理好再給我們

撿肥皂 回答

這個(gè)因?yàn)閑xcel會處理超過一定位數(shù)的大數(shù)字。解決方法可以試試在寫入前,將身份證那一列的數(shù)據(jù)類型強(qiáng)制轉(zhuǎn)換為字符串或者說object,即:
a['身份證號'] = a['身份證號'].astype('str')
試一試。