[Python] pandas_profiling main method not working correctly on Windows 10... Constructor works...

Discussão em 'Python' iniciado por Stack, Agosto 1, 2025.

  1. Stack

    Stack Membro Participativo

    df.profile_report() fails immediately after installation using import pandas_profiling

    The package is installed properly, because I can generate a report in Jupyter by importing and using just the constructor ProfileReport(df). However, the syntax df.profile_report() does not work.

    When I run df.profile_report() I get an error message below:

    ```AttributeError Traceback (most recent call last)
    in
    ----> 1 df.profile_report()

    C:\Anaconda3\envs\quantecon\lib\site-packages\pandas\core\generic.py in getattr(self, name)
    5065 if self._info_axis._can_hold_identifiers_and_holds_name(name):
    5066 return self[name]
    -> 5067 return object.getattribute(self, name)
    5068
    5069 def setattr(self, name, value):

    AttributeError: 'DataFrame' object has no attribute 'profile_report'
    ```


    Version information:


    • Python 3.7.1


    • pandas==0.24.2


    • Windows 10 2022H2

      import pandas as pd
      from pandas_profiling import ProfileReport

      # The dataframe is the same as the tutorial example given by the author.

      df = pd.DataFrame(np.random.rand(100, 5), columns=['a', 'b', 'c', 'd', 'e'])

      df.profile_report() # this fails.```

    What else I've tried that does work is as follows: from pandas_profiling import ProfileReport ...steps to create dataframe df ProfileReport(df)

    Using the constructor ProfileReport(df) by itself at least gets me a report in my Jupyter Notebook. Because of this I know the package is installed and working. However, the object.method() route to get the report doesn't work. But many other methods rely on the object.method() syntax.

    I cannot get any dataframes work with the df.profile_report() method.


    ```import numpy as np
    import pandas as pd
    from pandas_profiling import ProfileReport

    # The dataframe is the same as the tutorial example given by the author.

    df = pd.DataFrame(
    np.random.rand(100, 5),
    columns=['a', 'b', 'c', 'd', 'e']
    )

    df.profile_report() # this fails.
    ProfileReport(df) # this works, but `df.profile_report()` does not work.
    ```


    My guess as to what's wrong...?

    Since the pandas error is referring to "generic.py" for Pandas Core DataFrame, and the error is "no attribute 'profile_report', perhaps it is the decorator that wraps the dataframe object and modifies it to give it the extra attribute method of .profile_report() ?? That is my guess. I don't know what's causing the error, since it works when I "peek under the covers" and use the report constructor directly. I just cannot use the other methods that rely on the object.method() syntax.

    Continue reading...

Compartilhe esta Página