0
나는 팬더 데이터 프레임을 색인과 함께 부울 값의 사각형 격자로 만들고이 열이 이웃을 가진 628 개의 선거 구민의 이름으로 만듭니다. 예 :팬더에서 기준과 일치하는 열 이름 반환하기
In[18]: adjacents.index
Out[18]:
Index(['Aberavon', 'Aberconwy', 'Aberdeen North', 'Aberdeen South',
'Aberdeenshire West & Kincardine', 'Airdrie & Shotts', 'Aldershot',
'Aldridge-Brownhills', 'Altrincham & Sale West', 'Alyn & Deeside',
...
'Wrekin, The', 'Wrexham', 'Wycombe', 'Wyre & Preston North',
'Wyre Forest', 'Wythenshawe & Sale East', 'Yeovil', 'York Central',
'York Outer', 'Yorkshire East'],
dtype='object', length=628)
In[19]: adjacents.columns
Out[19]:
Index(['Aberavon', 'Aberconwy', 'Aberdeen North', 'Aberdeen South',
'Aberdeenshire West & Kincardine', 'Airdrie & Shotts', 'Aldershot',
'Aldridge-Brownhills', 'Altrincham & Sale West', 'Alyn & Deeside',
...
'Wrekin, The', 'Wrexham', 'Wycombe', 'Wyre & Preston North',
'Wyre Forest', 'Wythenshawe & Sale East', 'Yeovil', 'York Central',
'York Outer', 'Yorkshire East'],
dtype='object', length=628)
맨체스터 센트럴 구성은 맨체스터 고튼 (Manchester Gorton)과 인접하지만 맨체스터 위 핑턴 (Manchester Withington)과 인접하지 않습니다.
In[20]: adjacents['Manchester Central']['Manchester Withington']
Out[20]: False
In[21]: adjacents['Manchester Central']['Manchester Gorton']
Out[21]: True
True
입니다 행의 모든 열에 대한 열 이름을 반환하는 가장 좋은 방법은 무엇입니까? (나는 np.argmax()
함께 할 수있는 뭔가가 될 수도 있지만 확실히 그것을 알아낼 수 있다고 생각합니다.)