捷徑

torcharrow.DataFrame.select

DataFrame.select(*args, **kwargs)

類似於 SQL 的 SELECT

透過選擇舊欄位和新的(計算的)欄位來轉換資料框架。

特殊符號 me 可用於指代自身。

參數:
  • args (位置字串引數) – 投影中要保留的欄位名稱。「*」欄位名稱是表示所有欄位的捷徑。以「-」開頭的欄位名稱表示移除此欄位。

  • kwargs (具名值引數) – 要新增到投影的新欄位名稱運算式

範例

>>> from torcharrow import ta
>>> xf = ta.dataframe({
>>>    'A': ['a', 'b', 'a', 'b'],
>>>    'B': [1, 2, 3, 4],
>>>    'C': [10,11,12,13]})
>>> xf.select(*xf.columns,D=me['B']+me['C'])
  index  A      B    C    D
-------  ---  ---  ---  ---
      0  a      1   10   11
      1  b      2   11   13
      2  a      3   12   15
      3  b      4   13   17
dtype: Struct([Field('A', string), Field('B', int64), Field('C', int64), Field('D', int64)]), count: 4, null_count: 0

使用 ‘*’ 和 ‘-colname’

>>> xf.select('*','-B',D=me['B']+me['C'])
  index  A      C    D
-------  ---  ---  ---
      0  a     10   11
      1  b     11   13
      2  a     12   15
      3  b     13   17
dtype: Struct([Field('A', string), Field('C', int64), Field('D', int64)]), count: 4, null_count: 0

文件

存取 PyTorch 的完整開發者文件

檢視文件

教學

取得適用於初學者和進階開發者的深入教學課程

檢視教學課程

資源

尋找開發資源並獲得問題解答

檢視資源