我需要在dll中调用一个函数并返回一个结构数组.我事先并不知道阵列的大小.如何才能做到这一点?错误can not marshal 'returns value' invalid managed / unmanaged
C#中的代码:
[DllImport("CppDll"]
public static extern ResultOfStrategy[] MyCppFunc(int countO, Data[] dataO, int countF, Data[] dataF);
Run Code Online (Sandbox Code Playgroud)
在C++中:
extern "C" _declspec(dllexport) ResultOfStrategy* WINAPI MyCppFunc(int countO, MYDATA * dataO, int countF, MYDATA * dataF)
{
return Optimization(countO, dataO, countF, dataF);
}
Run Code Online (Sandbox Code Playgroud)
返回结构数组:
struct ResultOfStrategy
{
bool isGood;
double allProfit;
double CAGR;
double DD;
int countDeals;
double allProfitF;
double CAGRF;
double DDF;
int countDealsF;
Param Fast;
Param Slow;
Param Stop;
Param Tp;
newStop stloss;
};
Run Code Online (Sandbox Code Playgroud) 我有一个DataFrame这样的:
index B
0 1
1 2
2 5
3 6
4 7
5 10
Run Code Online (Sandbox Code Playgroud)
我需要合并差值小于或等于 2 的行,选择值较小的行并设置计数合并
结果应该是这样的:
index B count
0 1 2
1 5 3
2 10 1
Run Code Online (Sandbox Code Playgroud)
如何使用 pandas 解决这个问题?