Skip to content

Instantly share code, notes, and snippets.

import wsgiref.handlers
from google.appengine.ext import webapp
import os
from google.appengine.ext.webapp import template
class MainHandler(webapp.RequestHandler):
def get(self):
fpath =os.path.join(os.path.dirname(__file__),'views','index.html')
html = template.render(fpath, None)
self.response.out.write(html)
@northface
northface / gist:4571193
Created January 19, 2013 07:17
テスト
テストだよ。
@northface
northface / Suryoka3rui.py
Last active September 27, 2021 08:49
Pythonによる数量化三類プログラム
# coding: UTF-8
#-------------------------------------------------------------------------------
# Name: 数量化3類実行プログラム
# Purpose: 数量化3類をPython Numpyで実行する
# Reference: Excelで学ぶコレスポンデンス分析,高橋信,オーム社,2005
# Author: Takao Aoki
# Created: 2013/01/20
# Copyright: Takao Aoki(c) 2013
# Licence: GNU GPL
# Description: 数量化3類とは、生データの回答者および変数に生データの情報が
@northface
northface / parse_date_pandas.py
Last active June 20, 2017 13:24
CSV読み込み時に文字列の日付を解読する
#parse_datesをで対象の列を指定すると文字列の20170601を2017-06-01の日付型にしてくれる
import pandas as pd
df_pic = pd.read_csv("data/社員マスタ.csv",index_col="社員コード", parse_dates=['入社日付'] )
df_pic.info()
@northface
northface / subtraction_date_pandas.py
Last active June 20, 2017 13:23
pandasで日付の差分を取る方法
dt = pd.datetime.now().date()
df_pic['経験年数'] = ((dt - df_pic['入社日付'].dt.date).dt.days / 365).round(0).astype(int)
df_pic.head()
def graph_histogram(data,title,binwidth=5):
"""
ヒストグラムを描く関数
"""
plt.hist(data, bins=range(0, max(data)+1+ binwidth, binwidth))
plt.title(title)
plt.xlabel("day")
@northface
northface / read_fitbit_hr_json_data.py
Last active June 20, 2017 13:10
手元にあったFitbitの心拍データの読み込み
import matplotlib.pyplot as plt
import pandas as pd
import glob
%matplotlib inline
csv_files_hr = glob.glob('HR/*.json')
heart_df = pd.DataFrame()
for f in csv_files_hr:
hr = pd.read_json(f,typ='series')
@northface
northface / gbm_example_h2o.ipynb
Last active July 16, 2017 02:22
GBM Example by H2O.ai
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@northface
northface / 濁点・半濁点の置換.ipynb
Last active July 23, 2017 00:04
濁点「゛」・半濁点「゜」のある文字が一文字として扱われない時に置換するための方法(例:「ば」(1文字)→「は゛」(2文字)のようなケース)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@northface
northface / unixtime_and_datetime.ipynb
Created July 23, 2017 09:05
時間がうろ覚えのためメモ
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.