numpy & pandasの講座の演習課題でハマったのでメモ。 環境は、anaconda3でまとめてインストールした、python3.6.5、pandas0.23.0 DataFrameの値を変更したいときはqueryではなくlocを使う。 例えばこんなDataFrameがあったとする In [2]: df = pd.DataFrame({"score":[10, 20, 30], ...: "address":["Kashiwa", "Matsudo", "Noda"], ...: "weight":[70, 80, 90]}, ...: columns = ["score", "weight", "address"]) ...: df.index = ["Taro", "Jiro", "Hanako"] ...: df ...: Out[2]: score weight addres
Deleted articles cannot be recovered. Draft of this article would be also deleted. Are you sure you want to delete this article? はじめに 2018年のプロ野球レギュラーシーズンも残りわずかです。 今年は悪天候による中止が多く、クライマックスシリーズ初日にまだレギュラーシーズンの試合をやっているという不思議な年になりました…。 今年の注目は、なんと言っても野手最多タイ7球団競合の清宮幸太郎選手。現在の1軍成績は、あと2試合を残し、「.200 7本塁打 18打点」となっています。ルーキーにしては十分な活躍ではありますが、まだ打線の主軸を張れるような成績ではありません。当初の期待が大きすぎたために、イマイチなイメージを持たれている方も多いのではないのでしょうか。 とい
# 最大表示範囲を確認 pd.get_option("display.max_columns") pd.get_option("display.max_rows") # 表示範囲を指定(お好みで数値を設定) pd.set_option("display.max_columns",50) pd.set_option("display.max_rows",50) # その他のオプション dir(pd.options.display) # 実行結果 ['chop_threshold', 'colheader_justify', 'column_space', 'date_dayfirst', 'date_yearfirst', 'encoding', 'expand_frame_repr', 'float_format', 'height', 'html', 'large_repr', 'lat
python 初心者です。 1行に1つの数値データがある、長い行列のデータ群を規則に従って読み込んで、行列にする方法として、ベストな方法を検討しております。 <読み込みデータサンプル> 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 . . . と続くデータを、 次のような順番で並べて行列にしたいのですが。 <作りたい行列> 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5.. 上記の数値は、場所を示しています。 実際のデータは、ランダムな実数が入っています。 python,numpy,pandas.. どれで、どのように読み込めば、シンプルなプログラムになるでしょうか? <考え方> 1.一旦全部読み込んで、その後並べる。 2.1行ずつ読み込みながら、行列に配置して行く。 読み込むデータ行数は、10万行以上の行数を想定しています。 アドバイスよろしくお願いいたします。
#! /usr/bin/python # # csv_create.py # # Oct/01/2018 # ------------------------------------------------------------------ import sys import pandas as pd # # ------------------------------------------------------------------ sys.stderr.write("*** 開始 ***\n") # df = pd.DataFrame([ ["t1271","千葉",59476,"2003-9-21"], ["t1272","勝浦",49573,"2003-3-14"], ["t1273","市原",29471,"2003-6-25"], ["t1274","流山",39872
#! /usr/bin/python # # json_create.py # # Oct/01/2018 # ------------------------------------------------------------------ import sys import pandas as pd # # ------------------------------------------------------------------ sys.stderr.write("*** 開始 ***\n") # df = pd.DataFrame({'t0921': ["宇都宮",41295,"2003-8-12"], 't0922': ["小山",41298,"2003-8-12"], 't0923': ["佐野",31925,"2003-5-20"], 't0924': ["足利",
#! /usr/bin/python # -*- coding: utf-8 -*- # # xlsx_create.py # # Oct/01/2018 # ------------------------------------------------------------------ import sys import pandas as pd # # ------------------------------------------------------------------ sys.stderr.write("*** 開始 ***\n") # df = pd.DataFrame([ ["t1271","千葉",59476,"2003-9-21"], ["t1272","勝浦",49573,"2003-3-14"], ["t1273","市原",29471,"2003-6-
#! /usr/bin/python # -*- coding: utf-8 -*- # # sqlite3_create.py # # Oct/01/2018 # ------------------------------------------------------------------ import sys import pandas as pd # import sqlite3 # ------------------------------------------------------------------ sys.stderr.write("*** 開始 ***\n") # df = pd.DataFrame([ ["t1271","千葉",51476,"2003-9-25"], ["t1272","勝浦",42573,"2003-3-16"], ["t1273","
#! /usr/bin/python # -*- coding: utf-8 -*- # # mariadb_create.py # # Oct/01/2018 # ------------------------------------------------------------------ import sys import pandas as pd # import mysql.connector from sqlalchemy import create_engine # ------------------------------------------------------------------ sys.stderr.write("*** 開始 ***\n") # df = pd.DataFrame([ ["t1271","千葉",51476,"2003-9-25"],
#! /usr/bin/python # # postgre_create.py # # Mar/05/2023 # ------------------------------------------------------------------ import sys import pandas as pd # from sqlalchemy import create_engine # ------------------------------------------------------------------ sys.stderr.write("*** 開始 ***\n") # df = pd.DataFrame([ ["t1271","千葉",58471,"2003-9-25"], ["t1272","勝浦",49523,"2003-3-16"], ["t1273","市原
#! /usr/bin/python # -*- coding: utf-8 -*- # # html_create.py # # Oct/01/2018 # ------------------------------------------------------------------ import sys import pandas as pd # # ------------------------------------------------------------------ sys.stderr.write("*** 開始 ***\n") # df = pd.DataFrame([ ["t1271","千葉",93416,"2003-11-5"], ["t1272","勝浦",47573,"2003-6-14"], ["t1273","市原",28451,"2003-9-
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く