1

I have a DataFrame called Tabla. I am applying a function (called func11) to each column which basically is for plotting a specific row against other row (yes, is for plotting a single data point per column).

My question is: how can I pass attribute Series as arguments in my func11 so I can have a better control of the rows to be plotted?

Part of my Tabla is shown below:

                 G13          G42
RH1_0_i      12.7973      25.3097
RH2_0_i     -3.51892      85.2268
RH1_0        6700.17     -8888.33
RH2_0           7613     -7945.33
n1       2.30668e+11  2.23905e+11
n2       2.08436e+11  1.92139e+11

So, basically I want to call func11 with extra arguments like RH1_0_i or n1 which are Series attributes.

So far my code is:

Tabla.apply(func11)
def func11(x):
    plt.plot(x.RH1_0_i,x.n1)
    plt.plot(x.RH2_0_i,x.n2)

What I want is:

Tabla.apply(func11,extra_args=(arg1,arg2,arg3,arg4))
def func11(x,extra_args):
    plt.plot(x.arg1,x.arg3)
    plt.plot(x.arg2,x.arg4)
Ivanovitch
  • 358
  • 1
  • 2
  • 10

1 Answers1

0

Ok, thanks to the coment posted by amanb I figured out a way to do it:

def func12(x,x1,y1,x2,y2):
    X1,X2,Y1,Y2 = x[x1],x[x2],x[y1],x[y2]
    plt.plot(X1,Y1)
    plt.plot(X2,Y2)

Tabla.apply(func12,args=('RH1_0_i','n1','RH2_0_i','n2'))

So, in this way I can pass Series attribute as arguments in my function.

Ivanovitch
  • 358
  • 1
  • 2
  • 10