当我尝试使用以下代码加载它们时,我训练了两个模型以将它们组合起来:
from tensorflow.keras.models import load_model
models=[]
modelTemp=load_model('models/full.h5')
modelTemp.name = "inception1"
models.append(modelTemp)
Run Code Online (Sandbox Code Playgroud)
发生错误:
AttributeError: Can't set the attribute "name", likely because it conflicts with an existing read-only @property of the object. Please choose a different name.
Run Code Online (Sandbox Code Playgroud)
完整的错误信息:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/base_layer.py in __setattr__(self, name, value)
1968 try:
-> 1969 super(tracking.AutoTrackable, self).__setattr__(name, value)
1970 except AttributeError:
AttributeError: can't set attribute
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last)
2 frames
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/base_layer.py …
Run Code Online (Sandbox Code Playgroud) 您好,我正在尝试查找此错误的根本原因:
ValueError: You are trying to merge on object and int64 columns.
Run Code Online (Sandbox Code Playgroud)
我知道我可以使用 Pandasconcat
或merge
函数来解决这个问题,但我试图了解错误的原因。问题是:为什么我会得到这个ValueError
?
这是使用的两个数据帧上的head(5)
和的输出info()
。
print(the_big_df.head(5))
输出:
account apt apt_p balance date day flag month reps reqid year
0 AA0420 0 0.0 -578.30 2019-03-01 1 1 3 10 82f2d761 2019
1 AA0420 0 0.1 -578.30 2019-03-02 2 1 3 10 82f2d761 2019
2 AA0420 0 0.1 -578.30 2019-03-03 3 1 3 …
Run Code Online (Sandbox Code Playgroud) 我想知道是否通过以下方式选择了行:
groupby(['a', 'b'])
Run Code Online (Sandbox Code Playgroud)
与通过以下方式选择的行相同:
groupby(['b', 'a'])
Run Code Online (Sandbox Code Playgroud)
在这种情况下,行的顺序无关紧要。
有groupby
没有不满足交换性的情况?
不幸的是它不起作用:我有一个名为df
它由 5 列和 100 行组成。
我想在 x 轴第 0 列(时间)上绘制,在 y 轴上绘制相应的值。
我试过:
figure, ax1 = plt.subplots()
ax1.plot(df.columns[0],df.columns[1],linewidth=0.5,zorder=1, label = "Force1")
ax1.plot(df.columns[0],df.columns[2],linewidth=0.5,zorder=1, label = "Force2")
Run Code Online (Sandbox Code Playgroud)
但这是行不通的。
我无法直接寻址列名称 - 我只能使用列的编号(例如 1、2 或数字 3)。
感谢您的帮助!!!
赫尔穆特
count = 1
for i in range(10):
for j in range(0, i):
print(count, end='')
count = count +1
print()
input()
Run Code Online (Sandbox Code Playgroud)
我正在编写一个应该具有如下输出的程序.
1
22
333
4444
55555
666666
7777777
88888888
999999999
使用我编写的代码,我非常接近,但是我的计数工作方式只是字面数字上升.我只是需要帮助才能使它只计数到9但显示如上.谢谢.
目前,我正在研究这种数据集:
date income account flag day month year
0 2018-04-13 470.57 1000 0002 8 13 4 2018
1 2018-04-14 375.54 1000 0002 8 14 4 2018
2 2018-05-15 375.54 1000 0002 8 15 5 2018
3 2018-05-16 229.04 1000 0002 7 16 5 2018
4 2018-06-17 216.62 1000 0002 7 17 6 2018
5 2018-06-18 161.61 1000 0002 6 18 6 2018
6 2018-04-19 131.87 0000 0001 6 19 4 2018
7 2018-04-20 100.57 0000 0001 6 20 4 2018 …
Run Code Online (Sandbox Code Playgroud) 我正在寻找一种方法来生成基于多个列的平均值作为方法的排名,其中一个包含字符串,另一个包含整数(很容易超过2列,但为了简单起见,我限制为2列)。
import pandas as pd
df = pd.DataFrame(data={'String':['a','a','a','a','b','b','c','c','c','c'],'Integer':[1,2,3,3,1,3,6,4,4,4]})
print(df)
String Integer
0 a 1
1 a 2
2 a 3
3 a 3
4 b 1
5 b 3
6 c 6
7 c 4
8 c 4
9 c 4
Run Code Online (Sandbox Code Playgroud)
这个想法是为了能够创建排名,以字符串的降序排列每一行,以升序排列整数,这将是输出:
Rank String Integer
0 2 c 4
1 2 c 4
2 2 c 4
3 4 c 6
4 5 b 1
5 6 b 3
6 7 a 1
7 8 a 2
8 9.5 a …
Run Code Online (Sandbox Code Playgroud) 我已经尝试了以下代码,它可以工作但没有生成预期的输出:
import pandas as pd
columns_total = [int(i/2) if i%2==0 else "id"+str(int(i/2)) for i in range(10)]+["sym"+str(i) for i in range(5)]
index_total = [i for i in range(5)]
df = pd.DataFrame(index=index_total,columns=columns_total)
Run Code Online (Sandbox Code Playgroud)
我得到的输出是:
0 id0 1 id1 2 id2 3 id3 4 id4 sym0 sym1 sym2 sym3 sym4
0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
1 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2 NaN …
Run Code Online (Sandbox Code Playgroud) python ×8
pandas ×5
python-3.x ×2
dataframe ×1
filtering ×1
join ×1
keras ×1
nested-loops ×1
plot ×1
rank ×1
tensorflow ×1