不能重寫array
的toString
方法,對于數(shù)組的操作使用 Arrays
類
Arrays.toString()
Arrays.deepToString()
二維數(shù)組toString
import pandas as pd
df = pd.DataFrame([['2018-3-8', 10],
['2018-3-9', 20],
['2018-3-10', 30],
['2018-3-11', 40],
['2018-3-12', 250],
['2018-3-13', 260],
['2018-3-14', 270],
['2018-3-15', 280]], columns=['日期', '數(shù)據(jù)1'])
def f(df):
return (df[2] - df[1] < 100) and df[2] > df[1] and (df[1] - df[0] < 100) and df[1] > df[0] #增長大于0小于100
df[pd.rolling_apply(df, window=3, func=f)['數(shù)據(jù)1'] == True] # 滿足條件的日期(展示的是連續(xù)三天的最后一天)
判斷每個ID是否有連續(xù)3天【數(shù)據(jù)1】增長都大于0小于100的日期吧。
拷貝對象,而不是引用對象,assign與...
一樣都是淺拷貝
let b = a.map(item=>{
return Object.assign({},item)
})
用copy.deepcopy吧。
Parameters
----------
deep : boolean or string, default True
Make a deep copy, including a copy of the data and the indices.
With ``deep=False`` neither the indices or the data are copied.
Note that when ``deep=True`` data is copied, actual python objects
will not be copied recursively, only the reference to the object.
This is in contrast to ``copy.deepcopy`` in the Standard Library,
which recursively copies object data.
if(this.moduleList[1]&&this.moduleList[1]. childModuleList)
沒想到SF有Haskell問題:)
其實(shí)你看Profiling的結(jié)果,in_range
的inherited %time
和inherited %alloc
都比larger_than
大,占了整個程序執(zhí)行的100%和93.3%。所以第一種方法快。
寫個rewrite rule也許可以對elem
和enumFromTo
進(jìn)行優(yōu)化。
試了寫rewrite rule,發(fā)現(xiàn)enumFromTo有inline,導(dǎo)致rewrite rule沒有生效,所以先自己實(shí)現(xiàn)一個myEnumFromTo
看看效果:
module Main where
{-# RULES
"elem/myEnumFromTo" forall (x::Integer) (n::Integer) (m::Integer) . elem x (myEnumFromTo n m) = x >= n && x <= m
#-}
{-# NOINLINE myEnumFromTo #-}
myEnumFromTo n m
| n == m = [n]
| otherwise = [n] ++ myEnumFromTo (n + 1) m
main = do
print $ {-# SCC larger_than #-} lth 100000000
print $ {-# scc in_range #-} inr 100000000
lth :: Integer -> Bool
lth x = (x >= 1 && x <= 65535000000000)
inr :: Integer -> Bool
inr x = let m = 65535000000000::Integer in
x `elem` (myEnumFromTo 1 m)
Profile結(jié)果是這樣的:
main Main app/Main.hs:(12,1)-(14,48) 0.0 15.8
individual inherited
COST CENTRE MODULE SRC no. entries %time %alloc %time %alloc
MAIN MAIN <built-in> 144 0 0.0 29.6 0.0 100.0
CAF GHC.Conc.Signal <entire-module> 252 0 0.0 0.9 0.0 0.9
CAF GHC.IO.Encoding <entire-module> 241 0 0.0 3.8 0.0 3.8
CAF GHC.IO.Encoding.Iconv <entire-module> 239 0 0.0 0.3 0.0 0.3
CAF GHC.IO.Handle.FD <entire-module> 231 0 0.0 47.3 0.0 47.3
CAF GHC.IO.Handle.Text <entire-module> 229 0 0.0 0.1 0.0 0.1
CAF GHC.Show <entire-module> 214 0 0.0 0.4 0.0 0.4
CAF GHC.Event.Thread <entire-module> 193 0 0.0 1.7 0.0 1.7
CAF GHC.Event.Poll <entire-module> 160 0 0.0 0.1 0.0 0.1
CAF:main1 Main <no location info> 286 0 0.0 0.0 0.0 0.0
main Main app/Main.hs:(12,1)-(14,48) 288 1 0.0 0.0 0.0 0.0
CAF:main2 Main <no location info> 284 0 0.0 0.0 0.0 0.0
main Main app/Main.hs:(12,1)-(14,48) 293 0 0.0 0.0 0.0 0.0
in_range Main app/Main.hs:14:32-48 294 1 0.0 0.0 0.0 0.0
inr Main app/Main.hs:(20,1)-(21,29) 295 1 0.0 0.0 0.0 0.0
inr.m Main app/Main.hs:20:13-39 296 1 0.0 0.0 0.0 0.0
CAF:main4 Main <no location info> 285 0 0.0 0.0 0.0 0.0
main Main app/Main.hs:(12,1)-(14,48) 290 0 0.0 0.0 0.0 0.0
larger_than Main app/Main.hs:13:36-48 291 1 0.0 0.0 0.0 0.0
lth Main app/Main.hs:17:1-39 292 1 0.0 0.0 0.0 0.0
main Main app/Main.hs:(12,1)-(14,48) 289 0 0.0 15.8 0.0 15.8
還不知道怎讓才能對enumFromTo
生效:(
你這個是跑到最后一頁,沒有下一頁的鏈接所以提取不出來了吧。。。
login()
里面的.then(res =>res.data)
去掉
Python 的網(wǎng)頁解析一般有以下方法:
1.字符串方法
2.正則表達(dá)式
3.html/xml文本解析庫的調(diào)用(如著名的BeautifulSoup庫)
對于你所給的例子, 假設(shè):
>>> s = '<tr><td><b><a href=".././statistics/power" title="Exponent of the power-law degree distibution">Power law exponent (estimated) with d<sub>min</sub></a></b></td><td>2.1610(d<sub>min</sub> = 2) </td></tr>'
由于文本特征非常明顯, 可以這樣處理:
1.字符串處理方法:
>>> s.split('<td>')[-1].split('(d')[0]
'2.1610'
2.re:
>>> import re
>>> pattern = re.compile('</b></td><td>(.*)\(d<sub>')
>>> pattern.findall(s)
['2.1610']
3.BeautifulSoup:
>>> from bs4 import BeautifulSoup
>>> soup = BeautifulSoup(s, 'html.parser')
>>> soup.find_all('td')[1].contents[0][:-2]
'2.1610'
以上方法均是根據(jù)給定的例子臨時設(shè)計的.
已找到解決辦法。網(wǎng)頁中有段js是生成token的.
徑向漸變
定義若干顏色和透明,即形成若干同心圓。無需偽元素
把<p>里面的內(nèi)容整個提取出string來后用re提取。
r'\<br\>([\w\/]+)$'
當(dāng)然可以。 /\/start[^\/]+type\s*0[^\/]+\/end/g
$('.class').eq(index)
java.lang.NullPointerException
應(yīng)該是空指針異常引發(fā)的socke錯誤,檢查賦值操作為NULL的情況
先把你的那個counts轉(zhuǎn)換成字典,然后利用setdefault這個方法。
a_dict = {
"包" : 3,
"李" : 3,
"王" : 2,
"張" : 2,
"曹" : 2,
}
result = {}
for k, v in a_dict.items():
result.setdefault(v, []).append(k)
print(result)
>>> {3: ['包', '李'], 2: ['王', '張', '曹']}
建議你 看下 Rstan 關(guān)于 Garch 的例子,可以直接復(fù)用
按你的方式改變原數(shù)組
result.forEach(function (v) {
v.cfr_date.forEach(function (v2, i) {
if (i==v.cfr_date.length-1) {
v.cfr_date = v2;
} else {
var { ...c } = v;
c.cfr_date = v2;
result.push(c)
}
})
})
新數(shù)組
var new_result = result.reduce((arr, v) =>
v.cfr_date.reduce(function (arr2, v2) {
var { ...c } = v;
c.cfr_date = v2;
arr2.push(c)
return arr2;
}, arr)
, [])
一樓的finditer
方法是一個非常好的方法,它會返回一個迭代器,而不是返回所有的匹配數(shù)據(jù),這樣的好處一個是節(jié)省內(nèi)存,另一個是能逐個輸出,樓主可以參考,謝謝
最簡單的方式就是循環(huán)拆分一下唄。先上最簡單方法:
import pandas as pd
df = pd.DataFrame({'A':['1','2','3'],'B':['1','2,3','4,5,6'],'C':['3','3','3']})
result = pd.DataFrame(columns=['A','B','C'])
print(df,'\n')
for i in df.itertuples():
for j in i[2].split(','):
result = result.append({'A':i[1],'B':j,'C':i[3]},ignore_index=True)
print(result)
輸出:
A B C
0 1 1 3
1 2 2,3 3
2 3 4,5,6 3
A B C
0 1 1 3
1 2 2 3
2 2 3 3
3 3 4 3
4 3 5 3
5 3 6 3
采用expand
直接進(jìn)行擴(kuò)展
df = pd.DataFrame({'A':['1','2','3'],'B':['1','2,3','4,5,6'],'C':['3','3','3']})
df = (df.set_index(['A','C'])['B']
.str.split(',', expand=True)
.stack()
.reset_index(level=2, drop=True)
.reset_index(name='B'))
print(df)
北大青鳥APTECH成立于1999年。依托北京大學(xué)優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國家
北大青鳥中博軟件學(xué)院創(chuàng)立于2003年,作為華東區(qū)著名互聯(lián)網(wǎng)學(xué)院和江蘇省首批服務(wù)外包人才培訓(xùn)基地,中博成功培育了近30000名軟件工程師走向高薪崗位,合作企業(yè)超4
中公教育集團(tuán)創(chuàng)建于1999年,經(jīng)過二十年潛心發(fā)展,已由一家北大畢業(yè)生自主創(chuàng)業(yè)的信息技術(shù)與教育服務(wù)機(jī)構(gòu),發(fā)展為教育服務(wù)業(yè)的綜合性企業(yè)集團(tuán),成為集合面授教學(xué)培訓(xùn)、網(wǎng)
達(dá)內(nèi)教育集團(tuán)成立于2002年,是一家由留學(xué)海歸創(chuàng)辦的高端職業(yè)教育培訓(xùn)機(jī)構(gòu),是中國一站式人才培養(yǎng)平臺、一站式人才輸送平臺。2014年4月3日在美國成功上市,融資1
曾工作于聯(lián)想擔(dān)任系統(tǒng)開發(fā)工程師,曾在博彥科技股份有限公司擔(dān)任項目經(jīng)理從事移動互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍(lán)懿科技有限責(zé)任公司從事總經(jīng)理職務(wù)負(fù)責(zé)iOS教學(xué)及管理工作。
浪潮集團(tuán)項目經(jīng)理。精通Java與.NET 技術(shù), 熟練的跨平臺面向?qū)ο箝_發(fā)經(jīng)驗,技術(shù)功底深厚。 授課風(fēng)格 授課風(fēng)格清新自然、條理清晰、主次分明、重點(diǎn)難點(diǎn)突出、引人入勝。
精通HTML5和CSS3;Javascript及主流js庫,具有快速界面開發(fā)的能力,對瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁制作和網(wǎng)頁游戲開發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開發(fā)經(jīng)驗。曾經(jīng)歷任德國Software AG 技術(shù)顧問,美國Dachieve 系統(tǒng)架構(gòu)師,美國AngelEngineers Inc. 系統(tǒng)架構(gòu)師。