当我在我的程序中运行mean_acc()方法时,有%(min_groups,self.n_splits)),警告)错误...
def mean_acc():
models = [
RandomForestClassifier(n_estimators=200, max_depth=3, random_state=0),
LinearSVC(),
MultinomialNB(),
LogisticRegression(random_state=0)]
CV = 6
cv_df = pd.DataFrame(index=range(CV * len(models)))
entries = []
for model in models:
model_name = model.__class__.__name__
accuracies = cross_val_score(model, features, labels, scoring='accuracy', cv=CV)
for fold_idx, accuracy in enumerate(accuracies):
entries.append((model_name, fold_idx, accuracy))
cv_df = pd.DataFrame(entries, columns=['model_name', 'fold_idx', 'accuracy'])
print(cv_df.groupby('model_name').accuracy.mean())
Run Code Online (Sandbox Code Playgroud)
这些是我使用mean_acc()方法运行程序时显示的错误.我可以知道如何在下面解决这些错误吗?请帮助我看看上面导致这些错误的代码,谢谢!
% (min_groups, self.n_splits)), Warning)
C:\Users\L31307\PycharmProjects\FYP\venv\lib\site-packages\sklearn\model_selection\_split.py:626: Warning: The least populated class in y has only 1 members, which is too few. The minimum number of members in any …Run Code Online (Sandbox Code Playgroud) 当尝试使用 pandas 模块在 python 中运行该corr()方法时,出现以下错误:
FutureWarning: The default value of numeric_only in DataFrame.corr is deprecated. In a future version, it will default to False. Select only valid columns or specify the value of numeric_only to silence this warning.
print(df.corr())
Run Code Online (Sandbox Code Playgroud)
注意(只是为了澄清):-df是从 a 读取的数据帧的名称csv。
例如:-
import pandas as pd
df = pd.read_csv('Data.csv')
print(df.corr())
Run Code Online (Sandbox Code Playgroud)
问题仅在于corr()引发上述错误的方法:
FutureWarning: The default value of numeric_only in DataFrame.corr is deprecated. In a future version, it will default …Run Code Online (Sandbox Code Playgroud) 有人遇到过类似的吗FutureWarning?我在使用Tiingo+pandas_datareader时得到这个?
警告就像:
python3.8/site-packages/pandas_datareader/tiingo.py:234: FutureWarning: In a future version of pandas all arguments of concat except for the argument 'objs' will be keyword-only
return pd.concat(dfs, self._concat_axis)
Run Code Online (Sandbox Code Playgroud)
我认为这个警告不会影响我对 pandas 数据的访问(在我的例子中,我从 tiingo api 获取),我可以毫无问题地获取我想要的所有数据。我只是想了解我当前的环境是否存在任何风险:
my python3 - 3.8.5,
Python 3.8.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
pandas_datareader version - 0.10.0
pandas version - 1.3.2
Run Code Online (Sandbox Code Playgroud)
然后我用 python 的“futureVersion”测试了我的代码:3.9.6(与 python 3.8.5 相比)。令我惊讶的是,我不再收到任何警告或错误,一切正常:
以下是更新的详细信息
platform win32
- Python 3.9.6, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
Run Code Online (Sandbox Code Playgroud)
任何建议表示赞赏。
使用 openpyxl for python 加载 xlsm 文件时收到警告,然后在将一些数据添加到特定工作表中的特定 7 个单元格后保存/关闭它。问题是我收到了一个“FutureWarning”,我不知道它是关于什么的。我已经搜索了一段时间,但无法破译。
我怀疑 wb.save() 方法是触发此警告的原因,因为当我评论此特定行时它没有显示。
有谁知道这是什么?
代码
wb = openpyxl.load_workbook(filename=directory_path.xlsm, keep_vba=True)
ws = wb['sheetname']
ws.cell(row1, col1).value = ### (some number)
ws.cell(row2, col2).value = ### (some number)
ws.cell(row3, col3).value = ### (some number)
ws.cell(row4, col4).value = ### (some number)
ws.cell(row5, col5).value = ### (some number)
ws.cell(row6, col6).value = ### (some number)
ws.cell(row7, col7).value = ### (some number)
wb.save(directory_path.xlsm)
wb.close()
Run Code Online (Sandbox Code Playgroud)
警告信息
C:\Users\...\Anaconda3\lib\site-packages\openpyxl\comments\shape_writer.py:75: FutureWarning: The behavior of this method will change in future versions. Use specific …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 Python 中运行代码。
我上传的库如下:
import requests
import json
from datetime import datetime
import pandas as pd
import re
from pandas.io.json import json_normalize
Run Code Online (Sandbox Code Playgroud)
当我尝试从网站提取信息时,我收到以下错误:
C:\Users\Mike\anaconda3\lib\site-packages\ipykernel_launcher.py:1: FutureWarning: pandas.io.json.json_normalize is deprecated, use pandas.json_normalize instead
"""Entry point for launching an IPython kernel.
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?