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.

pandas的一些应用

pandas的一些应用

pandas的一些应用

pandas的一些应用

pandas的一些应用

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

pandas的一些应用

4.DataFrame.sort_values(byaxis=0ascending=Trueinplace=Falsekind='quicksort'na_position='last') Sort by the values along either axispandas的一些应用

pandas的一些应用

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

Return cumulative sum over requested axis.

pandas的一些应用


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

pandas的一些应用

pandas的一些应用

7.DataFrame.map

pandas的一些应用

pandas的一些应用

pandas的一些应用

pandas的一些应用

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:
pandas的一些应用


7.DataFrame.sample(n=Nonefrac=Nonereplace=Falseweights=Nonerandom_state=Noneaxis=None)     Returns a random sample of items from an axis of object. pandas的一些应用


8. dummy variables pandas的一些应用
pandas的一些应用
pandas的一些应用

pandas的一些应用

这里用df[['data1']].join(dummies)相当于直接删除了key这一列,把想要的直接加在后面了。

9.多维DataFrame的拆解

pandas的一些应用

pandas的一些应用

pandas的一些应用


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. pandas的一些应用

pandas的一些应用

11.groupby中使用函数

pandas的一些应用

pandas的一些应用