我想对数据帧中的每一列应用我的自定义ecdf函数,然后根据返回的x,y值绘制ecdf
自定义函数:def ecdf(df):
n = len(df)
x = np.sort(df)
y = np.arange(1, n+1)/n
return x, y
我的for循环尝试:
^{pr2}$
编辑以包含错误:AxisError Traceback (most recent call last)
in ()
2 #design a for-loop which applies ecdf() on each column in df and plots them separately
3 for col in sj_interpol_data.columns:
----> 4 x_col, y_col = ecdf(col)
5 ax = plt.figure()
6 ax = plt.plot(x_col, y_col, marker='.', linestyle='none')
in ecdf(df)
4 n = len(df)
5 #define x values - sorted values in array
----> 6 x = np.sort(df)
7 #define y values - maps location of each datapoint WR to their percentiles
8 y = np.arange(1, n+1)/n
C:\Anaconda3\lib\site-p