2015-04-09から1日間の記事一覧

<Python, pdandas> データフレームの上の文字列を切り取る

データフレーム上の文字列値を切り取る。 In [31]: df = pd.DataFrame([['abcdeft','hijklmn'],['0123456','7890ast']]) In [32]: df Out[32]: 0 1 0 abcdeft hijklmn 1 0123456 7890ast In [33]: df[0].str[0] Out[33]: 0 a 1 0 Name: 0, dtype: object In …

<Python, pandas> コマンドラインの出力を取り込み、データフレーム(DataFrame)へ

コマンドライン command lineの出力をpipeして、データフレームDataFrameへ取り込む方法。 いろいろ調べた結果下記で実行可能っぽい。 In [1]: %more aaa.csv a,b,c, 1,2,3, 4,5,6, In [2]: import subprocess In [3]: import pandas as pd In [4]: import i…

<Python> 2次元配列(ディクショナリ)の作り方

In [22]: d = {} In [23]: d['a'] = { 'x' : 'hoge', 'y' : 'hage', 'z' : 'hige' } In [24]: d['b'] = { 'x' : 'moge', 'y' : 'mage', 'z' : 'mige' } In [26]: d['a']['x'] Out[26]: 'hoge' にゃるほど。。。。。

<Python, pandas> データフレーム(DataFrame)上の文字列操作

データフレーム DataFrame の中の文字列の操作。 Working with Text Data — pandas 0.15.2 documentation API Reference — pandas 0.16.0 documentation いろいろできるらしい。

<Linux, iconv> 文字コードを変換する方法。

iconv -f <from encoding> -t <to encoding> <inputfile> -o <outputfile> 指定できるencodingは UTF-8 UTF-16 SJIS EUC-JP ISO-2022-JP iconv -l で他もいろいろ確認可能。 -oはちとトリッキー。 同じ名前を出力に指定するとファイルが空になって返ってくる。。。 なので、 function iconv() { iconv -f SJIS -t</outputfile></inputfile></to></from>…