pandas 使用技巧記錄

2021-09-28 16:57:07 字數 1167 閱讀 2123

這個drop_duplicate方法是對dataframe格式的資料,去除特定列下面的重複行。返回dataframe格式的資料。

dataframe.to_csv(「des_file」)

panda聚合分組

當檔案過大無法單次讀取到記憶體時,可以採用iterator進行多次讀取:

reader = pd.read_csv(『block_all.csv』,iterator=true)

reader.get_chunk(n)

示範**

df_event = pd.read_csv(

"/workspace/share_dir/event_sequence.csv"

,iterator=

true

)while

true

:try

: chunk = df_event.get_chunk(

10**4)

for index,row in chunk.iterrows():

your_process(

)except stopiteration:

break

Pandas 使用技巧(一)

pandas 的列表pd series 1,2,3,4 它會為每乙個資料設定乙個序號 dtype,列表中資料的格式 dataframe pandas 的矩陣,在pandas中叫做dataframe,它是乙個大的矩陣類似於二維的numpy,資料為numpy的資料,但是為每行指定索引和每一列指定索引,結...

pandas使用技巧總結 1

記錄工作中使用過的一些pandas技巧 匯入必要的庫 並設定路徑 對得到資料預處理 cs well data 壓裂段 str.split n 2,expand true 壓裂段形式 井號 層號 段號 str.split 對應list.split 以什麼分割,預設空格,n 分成幾段,預設 1 all ...

Pandas使用實用技巧

常見的需求是將某一列根據指定的分隔符拆分成多列。現有需求,根據指定的分隔符將其拆分為多行。例 df a b 0 a f 1b c h g 2d k 3 e l 現需要將其拆分為 df a b 0 a f 1b h 1c g 2d k 3 e l 實現過程如下 df pd.dataframe dfa ...