タグ

arrayに関するU1and0のブックマーク (4)

  • Best way to initialize and fill an numpy array?

    Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams Collectives™ on Stack Overflow Find centralized, trusted content and collaborate around the technologies you use most. Learn more about Collectives

    Best way to initialize and fill an numpy array?
    U1and0
    U1and0 2016/12/05
    a = np.empty(3) * np.nan shareimprove this answer edited Mar 14 '14 at 20:45 answered Mar 14 '14 at 19:45 shx2 28.9k54679 Thanks for modify in place hint. That is what was confusing me. – tbc Mar 14 '14 at 20:32 add a comment up vote 23 down vote You could also try: In [79]: np.full(3, np.nan) Out
  • Pass Pandas DataFrame to Scipy.optimize.curve_fit

    U1and0
    U1and0 2016/11/27
    Also note that xdata should be a (k, M) array, where k is the number of predictor variables (i.e. columns) and M is the number of observations (i.e. rows). You should therefore transpose your input dataframe so that it is (4, M) rather than (M, 4), i.e. table[['A', 'B', 'C', 'D']].T.
  • NumPy 配列の基礎 — 機械学習の Python との出会い

    NumPy 配列の基礎¶ ここでは,NumPy で最も重要なクラスである np.ndarray について, チュートリアルの方針 の方針に従い,最低限必要な予備知識について説明します. np.ndarray は, N-d Array すなわち,N次元配列を扱うためのクラスです. NumPy を使わない場合, Python ではこうしたN次元配列を表現するには,多重のリストが利用されます. np.ndarray と多重リストには以下のような違いがあります. 多重リストはリンクでセルを結合した形式でメモリ上に保持されますが, np.ndarray は C や Fortran の配列と同様にメモリの連続領域上に保持されます. そのため,多重リストは動的に変更可能ですが, np.ndarray の形状変更には全体の削除・再生成が必要になります. 多重リストはリスト内でその要素の型が異なることが許

  • Fancy Indexing:配列の一部を条件をつけて取り出す - おっぱいそん!

    aを適当なN次元配列とする。 a[a_1, a_2, a_3, ]とすると、配列の1つの成分を取り出せる。 a[リスト]とすると、1次元配列のリスト番目の成分のみ取り出した配列を返す。 (上の用に配列の1つの成分だけ取り出したい時にはtuple(リスト)のようにtupleにして渡せば良い) a[リスト1,リスト2,リスト3, ]とすると、1次元目をリスト1で2次元目をリスト2で、といったように取り出した配列を返す。 np.ix_をつかってa[np.ix_([行],[列])]とすると行列の一部の行と列のみ取り出した新しい行列を作れる。 ※ここまでのリストは配列にしても同じ。 同じことをbool値を使って、a[[行のbool],[列のbool],[3次元目のbool], ]とも出来る(これはリストにすると、False=0, True=1と解釈されるので注意)。 import numpy as

    Fancy Indexing:配列の一部を条件をつけて取り出す - おっぱいそん!
  • 1