1

Recently, I installed pandas_profiling for the purpose of a particular project I created in the PyCharm IDE. It worked after having updated 'External tools' in Settings. Realising a similar need in another project context I did the installation of pandas_profiling in …\venv\Scripts path for that particular project as well. Did similar update of External tools in the new project. Yet the console keeps telling me that it cannot detect the module. Both projects have the pandas_profiling package files in the 'site packages' and 'venv' directories when I check. Any ideas out there? Thx, for your kind support.

from pathlib import Path

import pandas as pd
import numpy as np
import requests

import pandas_profiling

if __name__ == "__main__":
    file_name = Path("C:\\Users\…..csv")
if not file_name.exists():
    data = requests.get(
        "C:\\Users\…..csv"
         )
        file_name.write_bytes(data.content)

    df = pd.read_csv(file_name)
    df["Feature_1"] = pd.to_datetime(df["Feature_1"], errors="coerce")

    # Example: Constant variable
    # df["source"] = "name of org"

    # Example: Boolean variable
    df["boolean"] = np.random.choice([True, False], df.shape[0])

    # Example: Mixed with base types
    df["mixed"] = np.random.choice([1, "A"], df.shape[0])

    # Example: Highly correlated variables
    df["Feature_2"] = df["Feature_2"] + np.random.normal(scale=5, size=(len(df)))

    # Example: Duplicate observations
    duplicates_to_add = pd.DataFrame(df.iloc[0:10])
    duplicates_to_add[u"Feature_1"] = duplicates_to_add[u"Feature_1"]

    df = df.append(duplicates_to_add, ignore_index=True)

    profile = df.profile_report(
    title="Report", correlation_overrides=["recclass"]
    )
    profile.to_file(output_file=Path("C:\\Users.....html"))

Response from console in new project (while working in existing project):

Traceback (most recent call last):
  File "C:/Users/.../PycharmProjects/.../Pandas_Profiling_2.py", line 8, in <module>
    import pandas_profiling
ModuleNotFoundError: No module named 'pandas_profiling'

Process finished with exit code 1
Newbie
  • 61
  • 1
  • 1
  • 6

0 Answers0