简体   繁体   中英

Getting error while importing panda in python 3.7

Getting the error while importing panda

Traceback (most recent call last):
  File "C:/Users/kj/PycharmProjects/kj/parsing.py", line 5, in <module>
    import pandas
  File "H:\Python\New\lib\pandas\__init__.py", line 23, in <module>
    from pandas.compat.numpy import *
  File "H:\Python\New\lib\pandas\compat\__init__.py", line 421, in <module>
    if LooseVersion(dateutil.__version__) < LooseVersion('2.5'):
  File "C:\Program Files\Python\Python37\Lib\distutils\version.py", line 52, in __lt__
    c = self._cmp(other)
  File "C:\Program Files\Python\Python37\Lib\distutils\version.py", line 337, in _cmp
    if self.version < other.version:
TypeError: '<' not supported between instances of 'str' and 'int'

import pandas
df = pandas.read_excel(open('Test.csv','rb'), sheetname='Sheet 1')
grouped = df.groupby('Date (IT)')

Looks like your Date (IT) column has mixed values (string and integers, dates, or missing values). So when pandas try to compare each value it fails because of different types. Please take a look at the column data and make sure all data is in a valid format.

I don't have PyCharm installed at the moment but in the command line you can try to run:

pip uninstall pandas 

followed by a reinstall : pip install pandas

Or you can always try to run it from PyCharm. It will automatically suggest to install the missing package.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM