2013-05-03 5 views
7

시리즈로 작업 중이며 파일에 쓸 때 시리즈 이름을 어떻게 바꿀 수 있는지 궁금합니다.팬더 시리즈 이름 바꾸기

Gene_Name,0 
A2ML1,15 
AAK1,8 

내가 다음 할 것을 권장합니다 :

Gene_Name,Count 
A2ML1,15 
AAK1,8 

참고 : 예를 들어, 내 출력 CSV는 다음과 같이 구성 내 헤더는 "Gene_Name, 0"이되고 싶지 않아하지만, "Gene_Name, Count." 이것을 어떻게 할 수 있습니까?

+0

당신이 시리즈 또는 DataFrame를 사용하고 있습니까? – waitingkuo

답변

10

"Count"를 계열 이름으로 만들려면 your_series.name = "Count"으로 설정하고 다음과 같이 to_csv를 호출하십시오 : your_series.to_csv("c:\\output.csv", header=True, index_label="Gene_Name").

2

는 또 다른 방법은 그것을 할 수 있습니다 :

s.to_frame("Count").to_csv("output.csv", header=True, index_label="Gene_Name") 

또는

s.reset_index(name="Count").to_csv("output.csv", header=True, index_label="Gene_Name")