草庐IT

infer_dtype

全部标签

java - 不兼容的类型 : inference variable T has incompatible bounds equality constraints: capture#1 of ? 扩展了 java.lang.Object

我正在尝试连接以运行查询以获取MongoDB中的所有记录,然后将记录转换为引用对象类型的列表,我将其作为调用类的泛型。代码运行良好并在Eclipse中实现了预期的结果,但在mavenbuild期间出现编译错误,maven和eclipse都引用相同的JDK(1.8)。有人可以帮我解决这个问题吗publicclassMongoPersistenceImpl{MongoDatabasedatabase=(MongoDatabase)MongoConnectImpl.getInstance().getConnection();publicListgetAll(TmodelObject){Mon

python - pandas ValueError : numpy. dtype 大小错误,尝试重新编译

我全新安装了OSX10.9.3并安装了pip,然后就安装了pipinstallpandaspipinstallnumpy两次安装似乎都非常愉快,并且运行时没有任何错误(尽管有无数警告)。当我尝试使用importpandas运行python脚本时,出现以下错误:numpy.dtypehasthewrongsize,tryrecompilingTraceback(mostrecentcalllast):File"./moen.py",line7,inimportpandasFile"/Library/Python/2.7/site-packages/pandas/__init__.py",

python - 使 Int64 成为默认的整数 dtype,而不是 pandas 中的标准 int64

我想要我的所有数据帧,无论它们是否由任何一个构造函数重载构建,是否源自.read_csv()、.read_xlsx()、.read_sql()或任何其他方法,以使用新的可空值Int64datatype作为所有整数的默认dtype,而不是int64。如果没有“好”的方法,我愿意不顾一切地去做这件事,包括子类化DataFrame或Series类,以及重新实现任意数量的方法和构造函数属性等。我的问题是,可以做到吗?如果可以,我会怎么做? 最佳答案 你可以使用这样的函数:defnan_ints(df,convert_strings=Fals

python - 我可以在生成随机值时指定一个 numpy dtype 吗?

我正在创建一个随机值的numpy数组,并将它们添加到包含32位float的现有数组中。我想使用与目标数组相同的dtype生成随机值,这样我就不必手动转换dtypes。目前我这样做:importnumpyasnpx=np.zeros((10,10),dtype='f')x+=np.random.randn(*x.shape).astype('f')我想做而不是最后一行是这样的:x+=np.random.randn(*x.shape,dtype=x.dtype)但是randn(实际上没有一个numpy.random方法)不接受dtype参数。我的具体问题是,是否可以在创建随机数时为随机数指

python - Numpy.dot 类型错误 : Cannot cast array data from dtype ('float64' ) to dtype ('S32' ) according to the rule 'safe'

为什么我在使用np.dot(a,b.T)时会收到此错误:TypeError:Cannotcastarraydatafromdtype('float64')todtype('S32')accordingtotherule'safe'a和b的类型是numpy.ndarray。我的NumPy版本是1.11.0。 最佳答案 只需从BrenBarn和WarrenWeckesser获取输入以提供应该运行的代码片段(通过将字符串转换为float):a=map(lambdax:float(x),a)b=map(lambdax:float(x),b)

python - Pandas :将 dtype 'object' 转换为 int

我在Pandas中读取了一个SQL查询,这些值以dtype'object'的形式出现,尽管它们是字符串、日期和整数。我能够将日期“对象”转换为Pandas日期时间dtype,但在尝试转换字符串和整数时出现错误。这是一个例子:>>>importpandasaspd>>>df=pd.read_sql_query('select*frommy_table',conn)>>>dfiddatepurchase1abc12016-05-2212abc22016-05-2903abc32016-05-2224abc42016-05-220>>>df.dtypesidobjectdateobjectp

python - Pandas 识别的所有 dtypes 是什么?

对于pandas,如果有任何数据类型,谁会知道(i)float64、int64(以及np.number的其他变体,例如float32、int8等)(ii)bool(iii)datetime64,timedelta64比如字符串列,总是有一个dtype的object?或者,我想知道,除了上面的列表中的(i)、(ii)和(iii)之外,是否有任何数据类型pandas不会使其成为dtype一个对象? 最佳答案 pandas从numpy借用它的dtypes。有关这一点的演示,请参见以下内容:importpandasaspddf=pd.Dat

python - NumPy 的 loadtxt() 和 genfromtxt 的 'dtype' 有哪些可用数据类型?

有哪些可用的numpy.loadtxt或numpy.genfromtxt用于导入具有不同数据类型的表数据,可用的缩写有哪些(例如i32表示整数)?Thispost演示了条件的使用,我很好奇是否有人可以详细说明。 最佳答案 除了np.sctypeDict,还有这些变量:In[141]:np.typecodesOut[141]:{'All':'?bhilqpBHILQPefdgFDGSUVOMm','AllFloat':'efdgFDG','AllInteger':'bBhHiIlLqQpP','Character':'c','Comp

python - Pandas 中的 dtype ('O' ) 是什么?

我在pandas中有一个数据框,我正在尝试找出它的值的类型。我不确定列'Test'的类型是什么。但是,当我运行myFrame['Test'].dtype时,我得到了;dtype('O')这是什么意思? 最佳答案 意思是:'O'(Python)objectsSource.Thefirstcharacterspecifiesthekindofdataandtheremainingcharactersspecifythenumberofbytesperitem,exceptforUnicode,whereitisinterpretedas

python - ValueError : numpy. dtype 大小错误,尝试重新编译

我刚刚在我的python2.7上安装了pandas和statsmodels包当我尝试“importpandasaspd”时,会出现此错误消息。任何人都可以帮忙吗?谢谢!!!numpy.dtypehasthewrongsize,tryrecompilingTraceback(mostrecentcalllast):File"",line1,inFile"C:\analytics\ext\python27\lib\site-packages\statsmodels-0.5.0-py2.7-win32.egg\statsmodels\formula\__init__.py",line4,in