2017-10-11 20 views
0

我有一個形狀爲(p,p)的熊貓數據框(3000,60630)。我正在研究一個二元分類問題。有12126個填充細節,每個代表墊。從pandas dataframe列號中減去一個預定義的值並返回新的編號

First 12126 columns-feature 1 
    2nd 12126 columns-feature 2 
    3rd 12126 columns-feature 3 
    4th 12126 columns-feature 4 
    5th 12126 columns feature 5 

In total 60630 columns. 

爲了簡化建築ML模型,我給出了列號從1到60630.But現在我需要檢索原始墊詳細信息。

對於每個12126列,我需要從1開始。我不想在原始數據框中進行更改。對於報告目的,我需要這些詳細信息。

Eg:12127 corresponds to pad1 
60630 corresponds to pad 12126 

回答

1

IIUC:

In [5]: df = pd.DataFrame(np.random.randint(100, size=(3, 60630))) 

In [6]: df.columns 
Out[6]: RangeIndex(start=0, stop=60630, step=1) 

In [7]: i = 0 

In [8]: df.iloc[:, 12126*i:12126*(i+1)].columns 
Out[8]: RangeIndex(start=0, stop=12126, step=1) 

In [9]: i = 1 

In [10]: df.iloc[:, 12126*i:12126*(i+1)].columns 
Out[10]: RangeIndex(start=12126, stop=24252, step=1) 
相關問題