小编Nav*_*jum的帖子

无法从 PIL 导入 PILLOW_VERSION

导入时,Python (Anaconda) 出现以下错误:

ImportError: cannot import name 'PILLOW_VERSION' from 'PIL'
Run Code Online (Sandbox Code Playgroud)

我尝试删除pillow然后conda install但错误仍然存​​在。

python python-imaging-library anaconda

21
推荐指数
4
解决办法
2万
查看次数

pandas.read_feather得到了意想不到的争论nthreads

我尝试将数据帧保存为羽毛格式,但在加载时我得到了错误

os.makedirs('tmp', exist_ok=True)
df_hist.to_feather('tmp/historical-raw')
Run Code Online (Sandbox Code Playgroud)

这是加载回数据集

df_hist= pd.read_feather('tmp/historical-raw')
Run Code Online (Sandbox Code Playgroud)

这给出了以下错误

read_feather() got an unexpected keyword argument 'nthreads'
Run Code Online (Sandbox Code Playgroud)

提前致谢

python pandas feather

9
推荐指数
1
解决办法
1692
查看次数

ArrowNotImplementedError:在数据帧上应用 pandas.to_feather 时出现 halffloat 错误

我有一个数据框,其中包含不同数据类型的列,包括日期。不,在做了一些修改后,我想将其保存为羽毛文件,以便以后访问它。但我在以下步骤中收到错误

historical_transactions.to_feather('tmp/historical-raw')

ArrowNotImplementedError: halffloat
Run Code Online (Sandbox Code Playgroud)

python pandas feather

8
推荐指数
1
解决办法
7115
查看次数

如何将 BeautifulSoup 对象保存到文件中,然后以 BeautifulSoup 的形式从中读取?

我想将 BeautifulSoup 对象保存到文件中。因此,我将其更改为字符串,然后将其写入文件。然后将其作为字符串读取后,我将字符串转换为 BeautifulSoup 对象。这在我的测试过程中会有所帮助,因为我正在抓取的数据是动态的。

url = "https://coinmarketcap.com/all/views/all/"
html = urlopen(url)
soup = BeautifulSoup(html,"lxml")
Run Code Online (Sandbox Code Playgroud)

像这样编写 soup 对象:

  new_soup = str(soup)
  with open("coin.txt", "w+") as f:
      f.write(new_soup)
Run Code Online (Sandbox Code Playgroud)

产生这个错误:

UnicodeEncodeError: 'charmap' codec can't encode 
characters in position 28127-28132: character maps to <undefined>
Run Code Online (Sandbox Code Playgroud)

另外,如果我能够将其保存到文件中,我将如何读取作为 BeautifulSoup 对象返回的字符串?

python beautifulsoup

3
推荐指数
1
解决办法
7365
查看次数

有没有办法在python中从列表中获取键,将字典值初始化为0?

我有一个列表用作字典的键,并且对应于键的每个值都将初始化为0。

python dictionary

0
推荐指数
1
解决办法
2651
查看次数