パンダから単一セルをフェッチするために使用する方がパフォーマンスと信頼性の面で優れていますDataFrame
: get_value()またはloc []?パンダの単一セルを正しくフェッチする方法:loc [index、column] VS get_value(index、column)
2
A
答えて
4
あなたが最後にdocsで情報を見つけることができます。
明示的に値を取得するための(非推奨df.get_valueに等量( 'A'、 'A'))
# this is also equivalent to ``df1.at['a','A']``
In [55]: df1.loc['a', 'A']
Out[55]: 0.13200317033032932
しかしそれを使用すれば警告はありません。
しかし、もし
チェックIndex.get_value
:1次元ndarrayからの値の
高速検索。あなたは
をやっているか知っている場合にのみiat
、at
、loc
、ix
を使用するので、私はより良いと思うこれをされる使用。
タイミング:
df = pd.DataFrame({'A':[1,2,3],
'B':[4,5,6],
'C':[7,8,9],
'D':[1,3,5],
'E':[5,3,6],
'F':[7,4,3]})
print (df)
In [93]: %timeit (df.loc[0, 'A'])
The slowest run took 6.40 times longer than the fastest. This could mean that an intermediate result is being cached.
10000 loops, best of 3: 177 µs per loop
In [96]: %timeit (df.at[0, 'A'])
The slowest run took 17.01 times longer than the fastest. This could mean that an intermediate result is being cached.
100000 loops, best of 3: 7.61 µs per loop
In [94]: %timeit (df.get_value(0, 'A'))
The slowest run took 23.49 times longer than the fastest. This could mean that an intermediate result is being cached.
100000 loops, best of 3: 3.36 µs per loop
関連する問題
- 1. リストを挿入する<string> Items of DataGrid-Column-Index 2
- 2. SetItemChecked(index、boolean)VS SetItemCheckState(index、Checkstate)
- 3. Cloudant json index vs text index
- 4. Computed Column(COALESCE vs CASE vs ISNULL)
- 5. パンダのデータフレーム:.INDEX
- 6. MySQL:単一列SUM(IF(cond、a、b))vs muti-column Sum()
- 7. jQuery .eq(index)vs [index]両方がオブジェクトを返す場合は?
- 8. ブートストラップデータターゲットv-forに$ indexを正しく渡す方法は?
- 9. Column in Pandas
- 10. .INDEX方法
- 11. SQLiteでCREATE INDEXを正しく行う方法
- 12. 'index'と 'list-index'の違い
- 13. Ruby#indexメソッドVSバイナリ検索
- 14. 注釈@Column(nullable = false)vs @NotNullの差
- 15. Flask-SQLAlchemyの違いdb.Column vs Column
- 16. パンダ.loc複数の割り当てと単一のもの
- 17. PHPExcel mixed Column Validation
- 18. facet_wrap fill by column
- 19. Silverlight DataGridTemplate Column
- 20. xml-data from text-column
- 21. 私のプログラム(VS 2008、C++)に説明( - > description-column)を追加する方法
- 22. index + 1 to with with index
- 23. Bash Stacked Column
- 24. URLを?indexから/ indexに変更してください。
- 25. Extjs 6.0 RadioButton Column
- 26. Java resultset max column?
- 27. Like '%Column values%'
- 28. map point columnグラフ内の単一のDatapointへの幅
- 29. geditの "Column Mode"?
- 30. .locを使用したパンダでのマルチセレクション
'GET_VALUE()' - ')私は(非推奨のget_value'についてのドキュメントでこの文を理解していない、より速く、より適切な – MaxU