Why do i have ''str' object has no attribute 'copy'' error?

Viewed 33

i'm currently trying to automatize data cleaning and i found a repository on GitHub that i'm currently trying to run on my device, but i have an error at running, here's the code:

from AutoClean.autoclean import AutoClean
import pandas as pd
resultat = 'result(11).xlsx'
pipeline = AutoClean(resultat)
for pipeline in self.pipeline:
    pipeline.output

The error i'm getting is:

File "C:\Users\radia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\AutoClean\autoclean.py", line 64, in __init__        
    output_data = input_data.copy()
AttributeError: 'str' object has no attribute 'copy'

Thanks for reading me,

2 Answers

According to the autoclean documentation, you need to pass in a pandas.DataFrame into the constructor, not a string as you have done.

try

from AutoClean.autoclean import AutoClean
import pandas as pd
resultat = pd.read_excel('result(11).xlsx')
pipeline = AutoClean(resultat)
for pipeline in self.pipeline:
    pipeline.output

You will probably need to pass some params to read_excel() to get it to load the right excel tab, etc...

From the Readme for Autoclean

AutoClean takes a Pandas dataframe as input

You are passing a string, not a dataframe.

Related