以下代码:
events = pd.read_csv("C:/Test/timeseries_events.csv")
users = pd.read_csv("C:/Test/timeseries_users.csv")
# Merge both
s1 = pd.merge(events, users, how ='left', on=['user_id']) # merge events and users df
s2 = s1[(s1["age"] > 30) & (s1["gender"] == 'm')].reset_index() # filter required data based on your conditions
s2['event_count'] = s2.groupby('user_id')['event_date'].transform('count') # Adds new column for count of events
s2 = s2[['user_id','age','event_count']] # Keep only required columns so that unique rows can be selected in the next step.
s3 = s2.drop_duplicates()
# Plot histogram using pd.plot()
s3.hist(column=['age'], bins=8, align= 'mid', rwidth=0.8, range = (30,70))
[Out]: array([[<matplotlib.axes._subplots.AxesSubplot object at 0x000000000FD037F0>]],
dtype=object)
给我编译错误:
nnBFAD.cpp:在函数“ void OptBF()”中:
nnBFAD.cpp:156:25:错误:无法在初始化double中将“ codi :: RealForward {aka codi :: ActiveReal>}”转换为“ double”
#include <codi.hpp>
...
codi::RealForward Gcodi[l];
for (int p = 0; p < l; p++)
{
...
double a = Gcodi[p];
}
提示?
答案 0 :(得分:1)
根据官方文档here,
RealForward
是一个赋值运算符已重载的类型,因此您可以为其赋一个double。
喜欢做
codi::RealForward a = 3.0;
当然没有定义相反的方向
这就是为什么您不能仅通过以下操作将 codi :: RealForward 直接转换为double的原因?
double a = Gcodi[p];
但是您可以在其上调用函数,即
double a = Gcodi[p].getGradient();
更新:
然后,您可以像这样分配一个带有Double的RealForward对象
double myDouble{3.3};
RealForward a = myDouble;
但直接从REalForwad分配双精度数是非法的:
RealForward a = ...;
double myDouble = a; //not valid!
其他示例
RealForward b = a * a; //this is ok because a * a is a double
答案 1 :(得分:0)
我为此找到了一个函数:getValue()
double a = Gcodi [p] .getValue();
中所述