Pandas 데이터 프레임: 색인 없이 인쇄
Pandas 데이터 프레임으로 작업할 때 데이터 프레임을 인쇄할 때 색인을 제외하는 것이 바람직할 수 있습니다. 또한 시간 부분만 표시하도록 datetime 객체를 변환하는 등 특정 열의 형식을 수정해야 할 수도 있습니다.
데이터 프레임을 인쇄할 때 인덱스를 제외하려면 to_string 메서드 내에서 index 매개 변수를 사용하세요. index=False로 설정하면 인쇄된 출력에서 인덱스가 제거됩니다.
<code class="python">df.to_string(index=False)</code>
예를 들어 다음 데이터프레임을 고려하세요.
User ID Enter Time Activity Number 0 123 2014-07-08 00:09:00 1411 1 123 2014-07-08 00:18:00 893 2 123 2014-07-08 00:49:00 1041
index=False와 함께 to_string 메서드를 사용하면 다음 출력:
User ID Enter Time Activity Number 123 00:09:00 1411 123 00:18:00 893 123 00:49:00 1041
특정 열의 형식을 수정하려면 strftime 메서드를 사용하세요. 이 메서드를 사용하면 datetime 객체를 변환하여 시간 부분만 표시할 수 있습니다. 예를 들어, Enter Time 열의 시간 부분만 표시하려면 다음 코드를 사용하십시오.
<code class="python">df['Enter Time'] = df['Enter Time'].dt.strftime('%H:%M:%S')</code>
이렇게 하면 Enter Time 열이 날짜 없이 시간만 표시되도록 수정됩니다.
이러한 기술을 결합하면 인덱스 없이 특정 열 형식을 사용하여 데이터프레임을 인쇄할 수 있습니다. 예를 들어 Enter Time 열의 시간 부분만 있고 인덱스 없이 데이터프레임을 인쇄하려면 다음 코드를 사용합니다.
<code class="python">print(df[['User ID', 'Enter Time', 'Activity Number']].to_string(index=False))</code>
이렇게 하면 다음과 같은 출력이 생성됩니다.
User ID Enter Time Activity Number 123 00:09:00 1411 123 00:18:00 893 123 00:49:00 1041
위 내용은 색인 없이 사용자 정의 열 형식을 사용하여 Pandas DataFrame을 인쇄하는 방법은 무엇입니까?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

forhandlinglargedatasetsinpython, usenumpyarraysforbetterperformance.1) numpyarraysarememory-effic andfasterfornumericaloperations.2) leveragevectorization foredtimecomplexity.4) managemoryusage withorfications data

inpython, listsusedyammoryAllocation과 함께 할당하고, whilempyarraysallocatefixedMemory.1) listsAllocatemememorythanneedInitiality.

Inpython, youcansspecthedatatypeyfelemeremodelerernspant.1) usenpynernrump.1) usenpynerp.dloatp.ploatm64, 포모 선례 전분자.

numpyissentialfornumericalcomputinginpythonduetoitsspeed, memory-efficiency 및 comperniveMathematicaticaltions

contiguousUousUousUlorAllocationScrucialForraysbecauseItAllowsOfficationAndFastElementAccess.1) ItenableSconstantTimeAccess, o (1), DuetodirectAddressCalculation.2) Itimprovesceeffiency theMultipleementFetchespercacheline.3) Itsimplififiesmomorym

slicepaythonlistisdoneusingthesyntaxlist [start : step : step] .here'showitworks : 1) startistheindexofthefirstelementtoinclude.2) stopistheindexofthefirstelemement.3) stepisincrementbetwetweentractionsoftortionsoflists

NumpyAllowsForVariousOperationsOnArrays : 1) BasicArithmeticLikeadDition, Subtraction, A 및 Division; 2) AdvancedOperationsSuchasmatrixmultiplication; 3) extrayintondsfordatamanipulation; 5) Ag

Arraysinpython, 특히 Stroughnumpyandpandas, areestentialfordataanalysis, setingspeedandefficiency


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

드림위버 CS6
시각적 웹 개발 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 Linux 새 버전
SublimeText3 Linux 최신 버전

맨티스BT
Mantis는 제품 결함 추적을 돕기 위해 설계된 배포하기 쉬운 웹 기반 결함 추적 도구입니다. PHP, MySQL 및 웹 서버가 필요합니다. 데모 및 호스팅 서비스를 확인해 보세요.

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.