I am attempting to run the following code to plot the explained variance after applying PCA on my dataframe:
(ggplot(pcaDF, aes(x = "Principal Components", y = "expl_var")) + geom_line() + geom_point())
However, I keep on getting this error message:
--------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) /var/folders/4q/z12sygps24zfmyncnf31fmdw0000gn/T/ipykernel_87587/3283535859.py in <module>
----> 1 from plotnine import *
2
3 (ggplot(pcaDF, aes(x = "Principal Components", y = "expl_var")) + geom_line() + geom_point())
~/anaconda3/lib/python3.7/site-packages/plotnine/__init__.py in <module>
----> 1 from .qplot import qplot # noqa: F401
2 from .ggplot import ggplot, ggsave # noqa: F401
3 from .ggplot import save_as_pdf_pages # noqa: F401
4 from .watermark import watermark # noqa: F401
5 from .mapping import * # noqa: F401,F403,E261
~/anaconda3/lib/python3.7/site-packages/plotnine/qplot.py in <module>
5 import pandas.api.types as pdtypes
6 import numpy as np
----> 7 from patsy.eval import EvalEnvironment
8
9 from .ggplot import ggplot
ModuleNotFoundError: No module named 'patsy'
My machine is a Mac and I am using JupyterLab and Anaconda navigator.
I then installed patsy using the terminal by running the following command:
pip3 install patsy
Collecting patsy
Downloading patsy-0.5.2-py2.py3-none-any.whl (233 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 233.7/233.7 kB 1.1 MB/s eta 0:00:00
Collecting numpy>=1.4
Downloading numpy-1.23.3-cp310-cp310-macosx_10_9_x86_64.whl (18.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 18.1/18.1 MB 1.8 MB/s eta 0:00:00
Collecting six
Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: six, numpy, patsy
Successfully installed numpy-1.23.3 patsy-0.5.2 six-1.16.0
I then restarted the kernel on jupyterlab but I am still getting the same error message above.
Please help!