numeric

php: how to change string data become numeric data

六月ゝ 毕业季﹏ 提交于 2019-12-02 13:34:54
can you tell how to change this result in php and mysql script: Model Class Ball S Book A Spoon Plate B Box C this is my DB: CREATE TABLE IF NOT EXISTS `inspection_report` ( `id` int(11) NOT NULL AUTO_INCREMENT, `Model` varchar(14) NOT NULL, `Serial_number` varchar(8) NOT NULL, `Lot_no` varchar(6) NOT NULL, `Line` char(5) NOT NULL, `Class` char(1) NOT NULL, `Status` varchar(6) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `Model` (`Model`,`Serial_number`,`Lot_no`,`Line`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=48 ; how if i want to show result like: Model s a b c Ball 1 0 0 0 Book 0 1

Numeric constants in enum (c#)

橙三吉。 提交于 2019-12-02 13:23:24
问题 I'm creating this selectbox in a SharePoint web part and need to have a drop down with the current version so I need to use an Enum. public enum SelectVersionEnum { 2010, 2007 }; Well you can see where it breaks, is there any way to use integers in a enum? Most of all I'd like to use public enum SelectVersionEnum { 2010=14, 2007=12 }; 回答1: No, you can not name enums with integer names. An enum value name is a normal identifier and must follow the same rules as everything else. You can,

pandas string to numeric

倖福魔咒の 提交于 2019-12-02 09:21:40
I have a set of data like a b 0 type 1 True 1 type 2 False How can I keep the numerical part of column a and transfer ture to 1, false to zero at the same time. Below is what I want. a b 0 1 1 1 2 0 You can convert Booleans to integers as follows: df['b'] = df.b.astype(int) Depending on the nature of your text in Column A , you can do a few things: a) Split on the space and take the second part (either string or int depending on your needs). df['a'] = df.a.str.split().str[1] # Optional `.astype(int)` b) Use regex to extract any digits ( \d* ) from the end of the string. df['a'] = df.a.str

R: convert list of numbers from character to numeric

霸气de小男生 提交于 2019-12-02 08:33:21
问题 I have a column in my dataframe where in every cell there are one or more numbers. If there are many numbers, they are seperated with a space. Furthermore, R considers them as a character vector. I'd really like to convert them to numeric (and if possible sum them up right away). E.g. one of my cells might look like 6 310 21 20 64 I've tried Reduce(sum,L) and as.numeric(L) but I always get Warning message: NAs introduced by coercion Here, L is just a sample object I created to put one of my

Factor with comma and percentage to numeric

元气小坏坏 提交于 2019-12-02 07:41:52
I have a column ("rates")which is a factor with several levels such as: 16 Levels: -0,186% -0,229% -0,326% ... When I try to convert it to numeric , NAs are introduced and I can't figure out how to do it properly. rates=as.numeric(gsub(",", ".", rates)) rates=as.numeric(sub("%", "e-2", rates)) I also tried the following, which was the answer to a similar question, but it does not work either. rates=as.numeric(gsub("\\%", "", rates)) Another option is to use the parse_number -function from the readr -package and specify that a comma is used as decimal mark: library(readr) parse_number(rates,

64-bit unsigned integers which cannot map onto a double [duplicate]

泪湿孤枕 提交于 2019-12-02 06:27:18
This question already has an answer here: Are all integer values perfectly represented as doubles? [duplicate] 5 answers Are there any 64-bit unsigned integer values which cannot be represented with a double-precision floating-point type? (As a double is also 64-bit wide there must be some.) If so, how can I calculate all of them? (In a not brute force way, maybe?) Every integer from 0 to 2^52 inclusive is representable exactly, from 2^52 to 2^53 only every even integer (lowest significant bit of 0), then every fourth integer, up to 2^64-2^12. We could generalise with a bit of code, taking m

Data frame typecasting entire column to character from numeric

谁说胖子不能爱 提交于 2019-12-02 04:36:32
Suppose I have a data.frame that's completely numeric . If I make one entry of the first column a character (for example), then the entire first column will become character . Question : How do I reverse this. That is, how do I make it such that any character objects inside the data.frame that are "obviously" numeric objects are forced to be numeric ? MWE: test <- data.frame(matrix(rnorm(50),10)) is(test[3,1]) test[1,1] <- "TEST" is(test[3,1]) print(test) So my goal here would be to go FROM the way that test is now, TO a state of affairs where test[2:10] is numeric . So I guess I'm asking for

R: convert list of numbers from character to numeric

天涯浪子 提交于 2019-12-02 04:15:40
I have a column in my dataframe where in every cell there are one or more numbers. If there are many numbers, they are seperated with a space. Furthermore, R considers them as a character vector. I'd really like to convert them to numeric (and if possible sum them up right away). E.g. one of my cells might look like 6 310 21 20 64 I've tried Reduce(sum,L) and as.numeric(L) but I always get Warning message: NAs introduced by coercion Here, L is just a sample object I created to put one of my cells into. Following my comment, here is a solution using sapply : sum(as.numeric(strsplit("6 310 21 20

Sort a list numerically in Python

我们两清 提交于 2019-12-02 04:15:25
问题 So I have this list, we'll call it listA. I'm trying to get the [3] item in each list e.g. ['5.01','5.88','2.10','9.45','17.58','2.76'] in sorted order. So the end result would start the entire list over again with Santa at the top. Does that make any sense? [['John Doe', u'25.78', u'20.77', '5.01'], ['Jane Doe', u'21.08', u'15.20', '5.88'], ['James Bond', u'20.57', u'18.47', '2.10'], ['Michael Jordan', u'28.50', u'19.05', '9.45'], ['Santa', u'31.13', u'13.55', '17.58'], ['Easter Bunny', u'17

Sort a list numerically in Python

ぐ巨炮叔叔 提交于 2019-12-02 02:08:11
So I have this list, we'll call it listA. I'm trying to get the [3] item in each list e.g. ['5.01','5.88','2.10','9.45','17.58','2.76'] in sorted order. So the end result would start the entire list over again with Santa at the top. Does that make any sense? [['John Doe', u'25.78', u'20.77', '5.01'], ['Jane Doe', u'21.08', u'15.20', '5.88'], ['James Bond', u'20.57', u'18.47', '2.10'], ['Michael Jordan', u'28.50', u'19.05', '9.45'], ['Santa', u'31.13', u'13.55', '17.58'], ['Easter Bunny', u'17.20', u'14.44', '2.76']] If you want to return the complete list in sorted order, this may work. This