set_index <-> reset_index
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"build_systems": | |
[ | |
{ | |
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", | |
"name": "Anaconda Python Builder", | |
"selector": "source.python", | |
"shell_cmd": "~/.virtualenvs/tensorflow/bin/python -u \"$file\"" | |
} | |
], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import gensim | |
from sklearn.feature_extraction.text import CountVectorizer | |
from gensim.corpora.dictionary import Dictionary | |
from gensim.corpora import MmCorpus | |
import numpy as np | |
import lda |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import pandas as pd | |
import numpy as np | |
from sklearn.datasets import load_digits | |
from sklearn import grid_search, metrics | |
from sklearn.pipeline import Pipeline, FeatureUnion | |
from sklearn.linear_model import LogisticRegression, RidgeClassifier, PassiveAggressiveRegressor, ElasticNet | |
from sklearn.ensemble import GradientBoostingRegressor, ExtraTreesRegressor, RandomForestRegressor | |
from sklearn.neighbors import KNeighborsClassifier, KNeighborsRegressor |
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#property indicator_chart_window | |
#property indicator_buffers 1 | |
#property indicator_color1 Red | |
// 指標バッファ | |
double BufMA[]; | |
// パラメータ | |
extern int MA_Period = 20; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hoge(): | |
print "hogehoge" |