基本上,我想这样做
ValueError: You are trying to merge on object and float64 columns. If you wish to proceed you should use pd.concat
错误是
Investments2['SECURITY CODE']
Name: SECURITY CODE, dtype: float64.
所以我检查right_on的类型:
Investments2['security code']
Out[104]:
116 11111
118 222222
119 333333
Name: security code, dtype: object
type(Investments2.iloc[1,1])
Out[106]: float
但是left_on会发生什么:
class TMyForm : public TForm
{
__published:
TEdit *Edit1;
TEdit *Edit2;
TEdit *Edit3;
TEdit *Edit4;
TEdit *Edit5;
void __fastcall EditChange(TObject *Sender);
private:
TEdit *Edits[5];
int __fastcall IndexOf(TEdit *Edit);
public:
__fastcall TMyForm(TComponent *Owner);
}
是不是一列浮点数是一个对象,而一个对象意味着一个字符串?
答案 0 :(得分:1)
在合并之前先转换Investments2
。喜欢,
Investments2['security code'] = Investments2['security code'].transform(float)
注释中指出的 或,请使用DataFrame.astype
Investments2['security code'] = Investments2['security code'].astype(float)