concatenation

Remove repeating data in a column

独自空忆成欢 提交于 2019-12-02 06:12:35
问题 I am currently developing an ordering system where a customer can order many items. I also have an admin where he/she can see all the orders on that day. The Admin can view the name of the customer, the total payable, the products and the quantity of the product the customer have ordered. I am currently seeing this results using my query. Name | Payable | Product | Quantity Test | 165 | keychain | 3 Test | 165 | Tumbler | 1 Miguel | 525 | Keychain | 3 Miguel | 525 | Magic Mug | 3 Dandel |

How to concatenate a const char array and a char array pointer?

佐手、 提交于 2019-12-02 05:54:14
Straight into business: I have code looking roughly like this: char* assemble(int param) { char* result = "Foo" << doSomething(param) << "bar"; return result; } Now what I get is: error: invalid operands of types ‘const char [4]’ and ‘char*’ to binary ‘operator<<’ Edit: doSomething returns a char* . So, how do I concatenate these two? Additional info: Compiler: g++ 4.4.5 on GNU/Linux 2.6.32-5-amd64 "Foo" and "Bar" are literals, they don't have the insertion ( << ) operator. you instead need to use std::string if you want to do basic concatenation: std::string assemble(int param) { std::string

Pandas: How to concatenate dataframes in the following manner?

旧城冷巷雨未停 提交于 2019-12-02 05:52:26
问题 I want to concatenate multiple dataframes into one dataframe. The manner I want the concatenation to happen is illustrated in the following example: Input tables: A B C D 0 x p 2 4 1 y q 3 5 A B E F 0 x p 6 8 1 y q 9 10 Output table: A B C D E F 0 x p 2 4 6 8 1 y q 3 5 9 10 I want to know if this can be done using the pandas.concat command. I know this can be done through the pd.merge command. Thanks. 回答1: Use set_index with list comprehension for MultiIndex and then concat: dfs = [df1, df2,

Initialize const char* by concatenating another char*

北战南征 提交于 2019-12-02 05:30:13
I want to refactor: const char* arr = "The " "quick " "brown"; into something like: const char* quick = "quick "; const char* arr = "The " quick "brown"; because the string "quick" is used is many other places. Ideally I need to be able to do this with just const primitive types, so no string. What is the best way to do this? Compiling the comments in the form of an answer: Use a macro. #define QUICK "quick " char const* arr = "The " QUICK "brown"; Use std:string . std::string quick = "quick "; std::string arr = std::string("The ") + quick + "brown"; Working code: #include <iostream> #include

concatenate unknown number of column and rows [duplicate]

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 04:44:19
This question already has an answer here: TEXTJOIN for xl2010/xl2013 with criteria 1 answer I am trying something since a couple of days and I am really lost about it. Could someone help me about it please. I would like to concatenate columns in Excel from the first column to the last non-empty column and add a comma between each column. Following that, I would like to apply the loop from the first line to the last non-empty line. I succeed to do it with a known number of column (I add the code after) but not when the number of column is unknown. Range("H2").Select ActiveCell.FormulaR1C1 = _ "

Runtime error while doing string concatenation

女生的网名这么多〃 提交于 2019-12-02 04:34:56
What is the problem with the below program? main( ) { char *str1 = "United" ; char *str2 = "Front" ; char *str3 ; str3 = strcat ( str1, str2 ) ; printf ( "\n%s", str3 ) ; } I am not able to compile the above program and it always give me runtime error. I am trying to concatenate the two string. Is there any error in the above program? Thanks. Make your char *str1 = "United" as char str1[<required memory for concatenated resultant string>] = "United" . You need to allocate memory for the destination buffer which is str1 . str3 will also receive address of str1 in the result. 'strcat' will not

Pandas Concatenate Values From Different Rows

不问归期 提交于 2019-12-02 04:33:55
Given this dataframe: import pandas as pd a=pd.DataFrame({'number':[2,2,3],'A':['abc','def','ghi']}) a A number 0 abc 2 1 def 2 2 ghi 3 I need to concatenate values, in order of index, from rows with the same number value, separated by '; '. Desired result: A number 0 abc; def 2; 2 2 ghi 3 So far, I thought I could isolate the dataframes and then somehow try to join them together like this: a['rank']=a.groupby('number').rank() a1=a.loc[a['rank']==1] a2=a.loc[a['rank']==2] b=a1.merge(a2,on='number',how='left') b=b.fillna('') b A_x number rank_x A_y rank_y 0 abc 2 1.0 def 2 1 ghi 3 1.0 ..and

Concatenate 2 rows in a complex SQL query

可紊 提交于 2019-12-02 04:06:13
I'm using MS-Access 2003 with the query creator. I select everything from one table ( FaitsSaillants ), then one specific row ( WHERE VARIABLE='TitreMandat' ) from another table ( tb_SOMMAIRE ). I want to select another row from that second table and concatenate it. The query PARAMETERS [CurrAxe] Text ( 255 ), [CurrOTP] Text ( 255 ), [CurrClient] Text ( 255 ), [StartDate] DateTime, [EndDate] DateTime; SELECT tb_SOMMAIRE.Valeur AS Projet, tb_SOMMAIRE.VARIABLE, * FROM (FaitsSaillants LEFT JOIN Employes ON FaitsSaillants.Utilisateur = Employes.CIP) INNER JOIN tb_SOMMAIRE ON FaitsSaillants.OTP =

How to concatenate multiple structure results vertically?

♀尐吖头ヾ 提交于 2019-12-02 04:04:43
If I have structure array and access it with matrix index, I get multiple anses. >> a=struct([]) a = 0x0 struct array with no fields. >> a(1).f1=[1;2] a = f1: [2x1 double] >> a(2).f1=[1;2;3] a = 1x2 struct array with fields: f1 >> a([1 2]).f1 ans = 1 2 ans = 1 2 3 What is the nature of this result? Can I generate it in other way? For example, may I write my own function or procedure, which will return such a result? Why assignment of this result gives first element, not last like in lists? >> b=a([1 2]).f1 b = 1 2 If I enclose such a result in brackets, I get automatic horizontal concatenation

Concatenation of a field related to multiple rows of a record in query set in Django

荒凉一梦 提交于 2019-12-02 03:53:00
问题 I have to models with one to many relation with which I try to distinguish the type of my records. Let's say First model is dedicated to Book information and second model is some types such as A, B , C and there is an indirect relation from the Type table to Book, so each book could be A, B or C or any possible combination of Types. I want to use concatenation (or any other possible function in annotation to gather all the types in a field). Book.objects.all( ).annotate( Types = F(