我的图表标题在这方面的位置很糟糕jointplot。我试过移动loc = 'left, right,center但它没有从它所在的位置移动。我也尝试过ax.title.set_position([3, 15])基于本网站其他建议的类似方法,但也根本没有移动它。关于控制标题位置的任何建议?
sns.jointplot(leagueWinners_season['Wins'], leagueWinners_season['Goals'], kind = 'reg', color = 'b')
plt.title('Season Winners Goal and Win Regression', loc = 'right', fontsize = 16)
plt.show()
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么这些白线将我的混淆矩阵分成四等分?我已经更改了许多参数,但无法弄清楚。使它们消失的唯一原因是我根本不标记块,即“0”、“1”……但这显然不是我想要的。任何帮助,将不胜感激。
代码:
def plot_confusion_matrix(cm,
target_names = ['1', '2', '3', '4'],
title = 'Confusion matrix',
cmap = None,
normalize = False):
"""
given a sklearn confusion matrix (cm), make a nice plot
Arguments
---------
cm: confusion matrix from sklearn.metrics.confusion_matrix
target_names: given classification classes such as [0, 1, 2]
the class names, for example: ['high', 'medium', 'low']
title: the text to display at the top of the matrix
cmap: the gradient of the values displayed from matplotlib.pyplot.cm
see http://matplotlib.org/examples/color/colormaps_reference.html
plt.get_cmap('jet') or plt.cm.Blues …Run Code Online (Sandbox Code Playgroud) 我的VSCode在默认目录下使用本地安装的anaconda环境,并将其放置在Program Files中。因此,我无法通过VSCode安装flake8,但出现权限错误。如果我在本地级别更新conda环境以安装flake8,那么有人知道VSCode是否能够识别并能够使用该软件包吗?
我有一个如下所示的数据框。该列Mfr Number是分类数据类型。我想对其进行预成型get_dummies或一种热编码,但如果它来自该行,我希望它填充该quantity列中的值,而不是用 1 填充新列。所有其他新的“假人”应在该行保持为 0。这可能吗?
Datetime Mfr Number quantity
0 2016-03-15 07:02:00 MWS0460MB 1
1 2016-03-15 07:03:00 TM-120-6X 3
2 2016-03-15 08:33:00 40.50699.0095 5
3 2016-03-15 08:42:00 40.50699.0100 1
4 2016-03-15 08:46:00 CXS-04T098-00-0703R-1025 10
Run Code Online (Sandbox Code Playgroud) 我正在规范Pandas中的一些数据,并且插入需要很长时间.数学似乎相对简单,只有约2500行.有更快的方法吗?
如下所示,我手动完成了规范化.
# normalize the rating columns to values between 0 and 1
df_1['numerator_norm'] = ((df_1['rating_numerator']- df_1['rating_numerator'].min())/(df_1['rating_numerator'].max()- df_1['rating_numerator'].min()))
df_1['denominator_norm'] = ((df_1['rating_denominator']- df_1['rating_denominator'].min())/(df_1['rating_denominator'].max()- df_1['rating_denominator'].min()))
df_1['normalized_rating'] = np.nan
for index, row in df_1.iterrows():
df_1['normalized_rating'][index] = (df_1['numerator_norm'][index] / df_1['denominator_norm'][index])
Run Code Online (Sandbox Code Playgroud)
这个过程只需几秒钟而不是60秒就可以了
我有一些代码,每当在B列中输入内容时,都应在A列中显示日期。我在安全设置中启用了宏,但仍然没有任何反应。我已将VBA代码张贴ThisWorkbook在该项目下,因为我希望每张纸上都发生同样的事情。有谁知道为什么它不会运行?
Private Sub Workbook_SheetChange(ByVal Sh As Object, _
ByVal Source As Range)
Dim WorkRng As Range
Dim Rng As Range
Dim xOffsetColumn As Integer
Set WorkRng = Intersect(Application.ActiveSheet.Range("B:B"), Target)
xOffsetColumn = -1
If Not WorkRng Is Nothing Then
Application.EnableEvents = False
For Each Rng In WorkRng
If Not VBA.IsEmpty(Rng.Value) Then
Rng.Offset(0, xOffsetColumn).Value = Now
Rng.Offset(0, xOffsetColumn).NumberFormat = "dd-mm-yyyy, hh:mm:ss"
Else
Rng.Offset(0, xOffsetColumn).ClearContents
End If
Next
Application.EnableEvents = True
End If
End Sub
Run Code Online (Sandbox Code Playgroud) 使用openpyxl版本2.6.1
这里有许多关于尝试格式化列的未解决的线程。我了解您目前无法格式化整个列...只能格式化单个单元格?尽管如此,我似乎连这一点都做不到。我正在尝试将列格式设置为'mm/dd/yyyy'. 我也知道NumberFormat()已经被删除了。我最后尝试过的“有效”(意味着这是我第一次运行代码并将其发布到Excel电子表格中)是下面的代码......但它不会格式化列,我在单元格中得到的结果B2是TRUE。我在这里缺少什么?
from openpyxl.styles import is_date_format, numbers
s = numbers.is_date_format('mm/dd/yy')
daily_runs_ws['B2'] = s
Run Code Online (Sandbox Code Playgroud)
11/14/2019 12:00:00 AM例如,当前的单元格格式(无需尝试编辑它) 。
I have a dictionary like so:
look_up = {1: ('January', str(now.year + 1) + '-01-01', '2020-01-31', 'E'),
2: ('February', str(now.year + 1) + '-02-01', '2020-02-29', 'F'),
3: ('March', str(now.year + 1) + '-03-01', '2020-03-31', 'G'),
4: ('April', str(now.year + 1) + '-04-01', '2020-04-30', 'H'),
5: ('May', str(now.year + 1) + '-05-01', '2020-05-31', 'I'),
6: ('June', str(now.year + 1) + '-06-01', '2020-06-30', 'J'),
7: ('July', str(now.year + 1) + '-07-01', '2020-07-31', 'K'),
8: ('August', str(now.year + 1) + '-08-01', '2020-08-31', 'L'), …Run Code Online (Sandbox Code Playgroud)