pandas的一些應用

1.DataFrame.sub(otheraxis='columns'level=Nonefill_value=None)(dataframe相減)

Subtraction of dataframe and other, element-wise (binary operator sub).

Equivalent to dataframe - other, but with support to substitute a fill_value for missing data in one of the inputs.


2.DataFrame.apply(funcaxis=0broadcast=Falseraw=Falsereduce=Noneargs=()**kwds)

Applies function along input axis of DataFrame.

Objects passed to functions are Series objects having index either the DataFrame’s index (axis=0) or the columns (axis=1). 

Return type depends on whether passed function aggregates, or the reduce argument if the DataFrame is empty.





3.DataFrame.sort_index(axis=0by=Noneascending=Trueinplace=Falsekind='quicksort')

Sort DataFrame either by labels (along either axis) or by the values in a column


4.DataFrame.sort_values(byaxis=0ascending=Trueinplace=Falsekind='quicksort'na_position='last') Sort by the values along either axis


5.DataFrame.cumsum(axis=Nonedtype=Noneout=Noneskipna=True**kwargs)

Return cumulative sum over requested axis.


6.DataFrame.dropna(axis=0how='any'thresh=Nonesubset=Noneinplace=False) Return object with labels on given axis omitted where alternately any or all of the data are missing


7.DataFrame.map





Like values in a Series, axis labels can be similarly transformed by a function or mapping of some form to produce new, differently labeled objects. You can also modify the axes in-place without creating a new data structure. Here’s a simple example:


7.DataFrame.sample(n=Nonefrac=Nonereplace=Falseweights=Nonerandom_state=Noneaxis=None)     Returns a random sample of items from an axis of object.


8. dummy variables




這裏用df[['data1']].join(dummies)相當於直接刪除了key這一列,把想要的直接加在後面了。

9.多維DataFrame的拆解





10.DataFrame.join(otheron=Nonehow='left'lsuffix=''rsuffix=''sort=False) Join columns with other DataFrame either on index or on a key column. Efficiently Join multiple DataFrame objects by index at once by passing a list.


11.groupby中使用函數





發佈了77 篇原創文章 · 獲贊 25 · 訪問量 14萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章