casting

forcing non-numeric characters to NAs in numpy (when reading a csv to a pandas dataframe)

微笑、不失礼 提交于 2019-12-11 11:33:05
问题 I have records where fields (called INDATUMA and UTDATUMA ) are supposed to comprise numbers in the range of 20010101 and 20141231 (for the obvious reason). To allow missing values but retain precision up to the nearest dates, I would store them as floats (np.float64). I was hoping this would force the occasionally misformatted field (think of 2oo41oo9) to NA s, but instead breaks the import both in pandas 0.18.0 or IOPro 1.7.2. Is there an undocumented option what could use? Or else? The key

SimpleDateFormat gives java.lang.classcastexception: java.util.date

三世轮回 提交于 2019-12-11 11:32:13
问题 String str = "13/06/2011"; SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); Date date = (Date)formatter.parse(str); 回答1: I guess that your Date class is actually a java.sql.Date . 回答2: What does your import statement say? Are you importing some other class (for example java.sql.Date ) by accident? What does the compiler say when you remove the class cast (which should not be there)? 回答3: DateFormat.parse() returns an instance of java.util.Date and not java.sql.Date . In order

Call Oracle Function from Visual Basic

六月ゝ 毕业季﹏ 提交于 2019-12-11 11:22:10
问题 Unsure why my code is returning an error when called from VB, however similar code in PLSQL (Oracle) isn't returning the error. Oracle Function: CREATE OR REPLACE FUNCTION GET_CUST_STRING_FROM_DB (pcustid NUMBER) RETURN VARCHAR2 AS returnstring VARCHAR2(200); vcustomer customer%rowtype; BEGIN SELECT * INTO vcustomer FROM customer WHERE custid = pcustid; returnstring := 'CustID: ' || vcustomer.custid || ' Name: ' || vcustomer.custname || ' Status: ' || vcustomer.status || ' SalesYTD: ' ||

Typecasting from int,float,char,double

早过忘川 提交于 2019-12-11 11:11:55
问题 I was trying out few examples on do's and dont's of typecasting. I could not understand why the following code snippets failed to output the correct result. /* int to float */ #include<stdio.h> int main(){ int i = 37; float f = *(float*)&i; printf("\n %f \n",f); return 0; } This prints 0.000000 /* float to short */ #include<stdio.h> int main(){ float f = 7.0; short s = *(float*)&f; printf("\n s: %d \n",s); return 0; } This prints 7 /* From double to char */ #include<stdio.h> int main(){

Wrong Value after type casting in 32 bit process [duplicate]

不问归期 提交于 2019-12-11 11:08:39
问题 This question already has answers here : Why does this floating-point calculation give different results on different machines? (4 answers) Closed 5 years ago . Please see the following code in C#. float a = 10.0f; float b = 0.1f; float c = a / b; int indirect = (int)(c); // Value of indirect is 100 always int direct = (int)(a / b); // Value of direct is 99 in 32 bit process (?) // Value of direct is 100 in 64 bit process Why do we get 99 in 32-bit processes? I am using VS2013. 回答1: When you

C++ - Cast template-type object to specific data types

南笙酒味 提交于 2019-12-11 11:07:07
问题 I'm using a template function searchByCriteria<T> where I would like to be able to run the function using both a string and a double . I have a list of custom-defined objects that have string and double attributes, and I would like to be able to use this function to check the criteria value (of whatever type, entered by the user), to check for matches in the object attributes of the same type. I.e. User enters a double value, check the object collection for matching double values. User enters

Class casting in java

早过忘川 提交于 2019-12-11 11:04:48
问题 In my code two classes are there ,subclass extends superclass.In sub class i override superclass method. On the time of object creation i created superclass reference to sub class object its working fine. But again i converted super class reference to complete super class object but it calls sub class methodn not super class method. My assumption the output is wrong.Here my code public class OverRiding { public static void main(String[] args) { // TODO Auto-generated method stub //Super class

C++ implicit numeric type demoting

北城以北 提交于 2019-12-11 10:53:27
问题 Recently, I have noticed that C/C++ seems to be very permissible with numeric type conversion, as it implicitly casts a double to int. Test: Environment: cpp.sh , Standard C++ 14 , Compilation warnings all set Code: int intForcingFunc(double d) { return d; // this is allowed } int main() { double d = 3.1415; double result = intForcingFunc(d); printf("intForcingFunc result = %f\n", result); int localRes = d; // this is allowed printf("Local result = %d\n", localRes); int staticCastRes = static

How can the following result of casting from float to numeric be explained?

瘦欲@ 提交于 2019-12-11 09:43:17
问题 DECLARE @f AS FLOAT = '29545428.022495'; SELECT CAST(@f AS NUMERIC(28, 14)) AS value; 29545428.02249500200000 Today I've read this example. I understand the problem of floating point numbers but do not understand the result of this casting. How it works? UPDATE First, we can replace varchar in the first line, the result will be the same. DECLARE @f AS FLOAT = 29545428.022495; Second, I think the problem is in casting. Try the following code. DECLARE @f AS FLOAT = 29545428.022495; select @f -

Specified cast is not valid C# Entity Framework

醉酒当歌 提交于 2019-12-11 09:20:10
问题 Hi I have been getting this Specified cast is not valid in my code but when I connect to my backup database I do not get the Specified cast is not valid error. I am not sure what is going on. Again, this code works perfectly on one database and gives me the error on the other. My Controller using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Data.Linq.SqlClient; using System.Text.RegularExpressions; using MvcPaging; using