這篇文章帶給大家的內容是關於python中Pandas的深入理解(程式碼範例) ,有一定的參考價值,有需要的朋友可以參考一下,希望對你有所幫助。
一、篩選
先建立一個 6X4 的矩陣資料。
dates = pd.date_range('20180830', periods=6) df = pd.DataFrame(np.arange(24).reshape((6,4)),index=dates, columns=['A','B','C','D']) print(df)
列印:
A B C D 2018-08-30 0 1 2 3 2018-08-31 4 5 6 7 2018-09-01 8 9 10 11 2018-09-02 12 13 14 15 2018-09-03 16 17 18 19 2018-09-04 20 21 22 23
簡單的篩選
如果我們想選取DataFrame
中的數據,下面描述了兩種途徑, 他們都能達到同一個目的:
print(df['A']) print(df.A) """ 2018-08-30 0 2018-08-31 4 2018-09-01 8 2018-09-02 12 2018-09-03 16 2018-09-04 20 Freq: D, Name: A, dtype: int64 """
讓選擇跨越多行或多列:
print(df[0:3]) """ A B C D 2018-08-30 0 1 2 3 2018-08-31 4 5 6 7 2018-09-01 8 9 10 11 """ print(df['20180830':'20180901']) """ A B C D 2018-08-30 0 1 2 3 2018-08-31 4 5 6 7 2018-09-01 8 9 10 11 """
如果df[3:3]
將會是一個空物件。後者選擇20180830
到20180901
標籤之間的數據,並且包括這兩個標籤。
也可以透過 loc
, iloc
, ix
來選擇。
相關推薦:
#以上是python中Pandas的深入理解(程式碼範例)的詳細內容。更多資訊請關注PHP中文網其他相關文章!

numpyArraysareAreBetterFornumericalialoperations andmulti-demensionaldata,而learthearrayModuleSutableforbasic,內存效率段

numpyArraySareAreBetterForHeAvyNumericalComputing,而lelethearRayModulesiutable-usemoblemory-connerage-inderabledsswithSimpleDatateTypes.1)NumpyArsofferVerverVerverVerverVersAtility andPerformanceForlargedForlargedAtatasetSetsAtsAndAtasEndCompleXoper.2)

ctypesallowscreatingingangandmanipulatingc-stylarraysinpython.1)usectypestoInterfacewithClibrariesForperfermance.2)createc-stylec-stylec-stylarraysfornumericalcomputations.3)passarraystocfunctions foreforfunctionsforeffortions.however.however,However,HoweverofiousofmemoryManageManiverage,Pressiveo,Pressivero

Inpython,一個“列表” isaversatile,mutableSequencethatCanholdMixedDatateTypes,而“陣列” isamorememory-sepersequeSequeSequeSequeSequeRingequiringElements.1)列表

pythonlistsandArraysareBothable.1)列表Sareflexibleandsupportereceneousdatabutarelessmory-Memory-Empefficity.2)ArraysareMoremoremoremoreMemoremorememorememorememoremorememogeneSdatabutlesserversEversementime,defteringcorcttypecrecttypececeDepeceDyusagetoagetoavoavoiDerrors。

Python和C 各有優勢,選擇應基於項目需求。 1)Python適合快速開發和數據處理,因其簡潔語法和動態類型。 2)C 適用於高性能和系統編程,因其靜態類型和手動內存管理。

選擇Python還是C 取決於項目需求:1)如果需要快速開發、數據處理和原型設計,選擇Python;2)如果需要高性能、低延遲和接近硬件的控制,選擇C 。

通過每天投入2小時的Python學習,可以有效提升編程技能。 1.學習新知識:閱讀文檔或觀看教程。 2.實踐:編寫代碼和完成練習。 3.複習:鞏固所學內容。 4.項目實踐:應用所學於實際項目中。這樣的結構化學習計劃能幫助你係統掌握Python並實現職業目標。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

Atom編輯器mac版下載
最受歡迎的的開源編輯器

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。

SublimeText3漢化版
中文版,非常好用

SecLists
SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。