【Wordpress】1ページサイトを作成する
利用準備
- 以下のページで会員登録する
ネットオウル /新規会員登録
・ メールアドレスを入力
・ 確認メールに記載のある認証IDを確認
・ 認証IDを入力し「登録フォームへ移動」をクリック
- 以下のページから管理画面にログインする
ネットオウル /ユーザーログイン - 提供サービスの中からWpblogの「新規申込」をクリック
- 新規インストール
・必要情報を入力
・「次へ進む」をクリック
・登録情報を確認し、「確定」をクリック
- 設定が終了するまで15分後程度待ちます
テーマの変更
plyrパッケージ
概要
- ある指定した特徴量に応じてデータを分割(Split)
- 分割したデータに対する関数の適用(Apply)
- 分割したデータを再結合して(list, data.frame, arrayでの)結果の出力(Combine)
という操作を一つの関数で実行することができる。
使い方
ddply
- 月毎の行数
ddply(tokyo.2014,.(month),nrow)
month V1 1 01 31 2 02 28 3 03 31 4 04 30 . . . . . .
- 月毎のA,B,C,D,E合計
ddply(tokyo.2014,.(month),colwise(sum,.(A,B,C,D,E)))
month A B C D E 1 01 22071 43799.0 15360 34747.0 11658.0 2 02 19727 45060.5 24549 35141.5 11569.5 3 03 35237 50806.0 24449 51871.0 28715.0 4 04 55324 88766.0 37782 85998.0 55821.0 . . . . . . . . . . . . . .
- 月、曜日毎のA,B,C,D,E平均値
ddply(tokyo.2014,.(month,week),colwise(mean,.(A,B,C,D,E)))
month week A B C D E 1 01 1 1027.800 1508.400 515.400 1065.600 369.800 2 01 2 583.200 1287.200 444.600 1102.400 376.200 3 01 3 673.600 1485.600 564.600 1365.400 394.000 . . . . . . . . . . . . . . . . 82 12 5 689.000 2120.000 453.000 1215.000 653.500 83 12 6 760.200 1787.600 495.600 1225.400 636.600 84 12 7 557.600 1706.800 583.200 1143.600 555.000
- 月毎に数値列の平均値を取得する
ddply(tokyo.2014,.(month),colwise(mean,is.numeric))
- numericな列のみを取得する
data[sapply(data,is.numeric)]
参考資料
【Android】今月の日数を確認する
import java.util.Calendar; import java.util.GregorianCalendar; public static int getDaysOfMonth(){ Calendar calendar = Calendar.getInstance(); int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH); Calendar c = new GregorianCalendar(year,month,1); int days=c.getActualMaximum(Calendar.DAY_OF_MONTH); return days; }
【Android】今日の日付を取得する
import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public static String getNowDate(){ Date now = new Date(System.currentTimeMillis()); DateFormat formatter = new SimpleDateFormat("yyyy年MM月dd日 HH時mm分"); String nowText = formatter.format(now); return nowText; }
【Python】SQLiteで構文中に変数を挿入する
テストプログラム
# -*- coding:utf-8 -*- import sqlite3 conn = sqlite3.connect("test.db") # テーブルの作成 conn.execute("create table tbl_name(id, name)") # データの挿入 conn.execute("insert into tbl_name values( ?, ? )", [ 1, "Sato" ]) # データの複数挿入 conn.executemany("insert into tbl_name values( ?, ? )", [ ( 2, "Suzuki" ), ( 3, "Tanaka" ) ]) conn.commit() conn.close()
解説
SQLite
SQLiteではデータ挿入は、以下の書式で行われます。
INSERT INTO テーブル名 VALUES(値1, 値2, ...);
例えば、「ID、名前、年齢、住所」のようなテーブルであれば、
create table user(id integer, name text, age integer, address text); insert into user values(1, 'Sato', 18, 'Tokyo');
上記のようにデータの挿入を行います。
Python
Pythonで上記と同様の事は、以下の記述で行えます。(中に名前のようにテキストを含むものをしていするときは、「"」と「'」のどちらかを入れ子にする必要があります.同様の文字を利用するとエラーになります.)
conn.execute("create table tbl_name(id integer,name text, age integer,address text)") conn.execute("insert into tbl_name values(1,'Sato')")
上記の記述に加えPython上では、「?」による変数の置き換えが可能です。(「[」部には勿論変数を指定可能です)
conn.execute("create table tbl_name(id integer,name text, age integer,address text)") conn.execute("insert into tbl_name values(?,?)",[1,"Sato"])
複数の変数を挿入する場合は、以下のような記述で可能です。
conn.execute("create table tbl_name(id integer,name text, age integer,address text)") conn.executemany("insert into tbl_name values( ?, ? )", [ ( 2, "Suzuki" ), ( 3, "Tanaka" ) ]) list = [(1,'Sato'),(2,'Suzuki'),(3,'Tanaka')] conn.executemany("insert into tbl_name values( ?, ? )", list)
結果の確認方法
SQLite
$ sqlite3 test.db sqlite3 > select * from tbl_name;
Python
# -*- coding:utf-8 -*- import sqlite3 conn = sqlite3.connect("test.db") cur = conn.cursor() cur.execute('select * from tbl_name') for r in cur.fetchall(): print r[0], r[1] conn.commit() conn.close() cur.close()
【Python】SQLiteでデータの読み込み
import sqlite3 conn = sqlite3.connect("test.db") cursor = conn.cursor() cursor.execute("select * from tbl_name where num >= 3") result = cursor.fetchall() for row in result: msg = msg + str(row[0]) + str(row[1]) + "\n" cursor.close() conn.close()
【Python】LINE APIでユーザIDを取得する
body = request.get_data(as_text=True) receive_json = json.loads(body) userId = receive_json["events"][0]["source"]["userId"]