Search code examples
pythonpandaspositional-argument

Missing 1 required position argument: 'self'


I'm having an issue with this: I'm getting the error "

bar() missing 1 required positional argument: 'self'

" I've tried fiddling this classes (using them and not using them) and with the self variable but I've got nothing. The function bar() comes from the pandas library I've imported as well as the dataframe (df) object. I've attached the main function of my code and the function in which the error is occurring.

def createDataframe(assessments):
    df = pd.DataFrame
    for review in assessments:   
        for skills in review.skillList:
            for skill in skills:
                tmp = pd.DataFrame({str(skill[:2]): [skill[3:]]})
                df.merge(tmp, how = 'right', right=tmp)
    return df

def plotData(df):
    ax = df.plot.bar(x='1.')
    plt.show()

def main():
    # Ensure proper CMD Line Arg
    if len(sys.argv) > 3:
        print("Error!")
        return 1
    assessments = dataParse()
    df = createDataframe(assessments)
    plotData(df)

Any help is welcome! Let me know!

EDIT: as tdy said in a comment below. I needed to add Parentheses to create an instance. Now I get no errors but I am left with nothing when printing df and nothing shows when plotting the information


Solution

  • Pandas data frame do not have an option for in-place merge. In your code when you merge df, then assign it back to df like so:

     df = df.merge(tmp, how=‘right’, right=tmp)