作者yshihyu (yshihyu)
看板Python
标题[问题] pandas 栏位内容比对
时间Sun Feb 19 00:42:11 2017
https://gist.github.com/anonymous/01d0536745d9814815081aa03d547bc7
上面程式码我想针对标题是 "获 利 状 况" 抓取表格
那要如何字串比对 "获 利 状 况" 找道是在list里面的哪个index?
下面是我测试 2103 股票在第41个index, 但其他档股票 "获 利 状 况" 可能不是在41 index
df2=pd.DataFrame(df[41])
http://goodinfo.tw/StockInfo/StockDetail.asp?STOCK_ID=2103
谢谢
--
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 111.71.54.71
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1487436137.A.4DC.html
※ 编辑: yshihyu (223.136.40.134), 02/19/2017 01:53:29
1F:→ physheepy: 资料量不大的话 if df[i].loc[0,0] == "XXXX": print i 02/19 02:42
3F:→ yshihyu: 你的方法可以但是list 里面有些资料型态不是unicode 02/19 05:43
4F:→ yshihyu: 会出现一些warning , 不知道这样如何处理? 02/19 05:43
5F:→ yshihyu: <type 'numpy.float64'> 遇到这就会出现 warning 02/19 05:44
6F:→ physheepy: 这样不会影响结果吧? 是数字的栏位就不是你要找的 02/19 11:17
7F:→ physheepy: warning 不是 error 02/19 11:18
8F:推 physheepy: 那个warning只是提醒你 你想比对的栏位不是 unicode 02/19 11:24