G:\PYthon\python_file\python_Machine_Lerning\python_machine_learning\venv\Scripts\python.exe G:\PYthon\python_file\python_Machine_Lerning\python_machine_learning\卡方检验.py
G:\PYthon\python_file\python_Machine_Lerning\python_machine_learning\卡方检验.py:1: DeprecationWarning:
Pyarrow will become a required dependency of pandas in the next major release of pandas (pandas 3.0),
(to allow more performant data types, such as the Arrow string type, and better interoperability with other libraries)
but was not found to be installed on your system.
If this would cause problems for you,
please provide us feedback at https://github.com/pandas-dev/pandas/issues/54466
import pandas as pd
Traceback (most recent call last):
File "G:\PYthon\python_file\python_Machine_Lerning\python_machine_learning\venv\Lib\site-packages\pandas\compat\_optional.py", line 135, in import_optional_dependency
module = importlib.import_module(name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\PYthon\python\Lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1140, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'openpyxl'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "G:\PYthon\python_file\python_Machine_Lerning\python_machine_learning\卡方检验.py", line 5, in <module>
home = pd.read_excel("home_income.xlsx")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\PYthon\python_file\python_Machine_Lerning\python_machine_learning\venv\Lib\site-packages\pandas\io\excel\_base.py", line 495, in read_excel
io = ExcelFile(
^^^^^^^^^^
File "G:\PYthon\python_file\python_Machine_Lerning\python_machine_learning\venv\Lib\site-packages\pandas\io\excel\_base.py", line 1567, in __init__
self._reader = self._engines[engine](
^^^^^^^^^^^^^^^^^^^^^^
File "G:\PYthon\python_file\python_Machine_Lerning\python_machine_learning\venv\Lib\site-packages\pandas\io\excel\_openpyxl.py", line 552, in __init__
import_optional_dependency("openpyxl")
File "G:\PYthon\python_file\python_Machine_Lerning\python_machine_learning\venv\Lib\site-packages\pandas\compat\_optional.py", line 138, in import_optional_dependency
raise ImportError(msg)
ImportError: Missing optional dependency 'openpyxl'. Use pip or conda to install openpyxl.
代码:
pandas pd
statsmodels.stats.contingency_tables tbl
home = pd.read_excel()
(home.head())
pd.crosstab(home.Ts9,home)
到底哪里出现了问题,我用的pycharm