python, pandas
In [1]: df
Out[1]:
apple banana cherry
0 0 3 good
1 1 4 bad
2 2 5 good
In [2]: df.loc[df.cherry == 'bad', ['apple', 'banana']] = np.nan
def hoge(): | |
print "hogehoge" |
#property indicator_chart_window | |
#property indicator_buffers 1 | |
#property indicator_color1 Red | |
// 指標バッファ | |
double BufMA[]; | |
// パラメータ | |
extern int MA_Period = 20; |
>>> import gensim | |
>>> sentences = [ | |
... ['human', 'interface', 'computer'], #0 | |
... ['survey', 'user', 'computer', 'system', 'response', 'time'], #1 | |
... ['eps', 'user', 'interface', 'system'], #2 | |
... ['system', 'human', 'system', 'eps'], #3 | |
... ['user', 'response', 'time'], #4 | |
... ['trees'], #5 | |
... ['graph', 'trees'], #6 | |
... ['graph', 'minors', 'trees'], #7 |
# https://labix.org/python-dateutil | |
from dateutil import rrule, parser | |
dt = parser.parse('2014-01-01') | |
for x in rrule.rrule(rrule.MONTHLY, dtstart=dt, count=3): | |
print(x) |
import pandas as pd | |
from lxml import html | |
# 出馬表 | |
denma_url = 'http://keiba.yahoo.co.jp/race/denma/1405040911/' | |
xpath = '//table' | |
denma_tree = html.parse(denma_url) | |
denma_table = denma_tree.xpath(xpath)[2] | |
denma_html = html.tostring(denma_table) | |
denma_html = denma_html.decode('utf-8').replace('<br>', '\\n') |
python, pandas
In [1]: df
Out[1]:
apple banana cherry
0 0 3 good
1 1 4 bad
2 2 5 good
In [2]: df.loc[df.cherry == 'bad', ['apple', 'banana']] = np.nan
set_index <-> reset_index
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
if __name__ == '__main__': | |
print "Hello, world!" |
<!-- add line number to gist --> | |
<script type="text/javascript"> | |
$('.gist').each(function() { | |
$('.line',this).each(function(i, e) { | |
$(this).prepend( | |
$('<div/>').attr('unselectable','on').css({ | |
'float' : 'left', | |
'width': '30px', | |
'font-weight' : 'bold', | |
'color': 'grey', |
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from FuncDesigner import * | |
from openopt import LP | |
# 変数の定義 | |
x1,x2 = oovars(2) | |
# 目的関数 | |
f = 3*x1 + 2*x2 | |
# 初期解 |