Merging strings that have identical rownames in a dataframe
Hi
I have a data frame with repeated names in column 1, and different descriptors in column 2. I want to merge/cat strings that have same entry in column 1 into one row with any separator.
I am looking to replace two or more strings on different lines using sed, but not with the same variable. IE
# cat xxx.file
<abc>
abc def ghi
abc def ghi
abc def ghi
currently I can only change each line with the same pattern:
# sed -e '/<abc>/!s/abc\(.*\)/jkl mno/' xxx.file
abc jkl mno... (3 Replies)
I have a sorted file like:
Apple 3
Apple 5
Apple 8
Banana 2
Banana 3
Grape 31
Orange 7
Orange 13
I'd like to search $1 and if $1 is not the same as $1 in the previous row print that row and print the number of times $1 was found.
so the output would look like:
Apple 8 3
Banana... (2 Replies)
Hi. I'm hoping that someone can help me with a bash script to delete a block of lines from a file.
What I want to do is delete every line between two stings that are the same,
including the line the first string is on but not the second.
(Marked lines to match with !)
For example if I... (2 Replies)
i have a problem in finding block of identical strings...i solved the problem in finding consecutive identical words and now i want to expand the code in order to find and remove consecutive identical block of strings...
for example the awk code removing consecutive identical word is:... (2 Replies)
i have a problem in finding block of identical strings...i solved the problem in finding consecutive identical words and now i want to expand the code in order to find and remove consecutive identical block of strings...
for example the awk code removing consecutive identical word is:... (2 Replies)
i have a problem in finding block of identical strings...i solved the problem in finding consecutive identical words and now i want to expand the code in order to find and remove consecutive identical block of strings...
for example the awk code removing consecutive identical word is:... (2 Replies)
Seems not very post about R language. Here is one: How to grep a sublist of a list like grep -f in unix? say I have a dataframe
ID v1 v2 v3
A 1 3 4
B 4 5 6
C 7 8 9
D 1 3 4
E 1 3 3
F 2 4 5 and I only need
ID v1 v2 v3
A 1 3 4
C 7 8 9
E 1 3 3
F 2 4 5 by like
grep... (2 Replies)
Dear all,
I need a little help. I am working on a frequency driven database in which the structure is as under:
headword=gloss<space>Frequency
The data which I am working with has dupes i.e. the Headword is repeated more than once with a different gloss variant on the right hand side and... (8 Replies)
hey,
i m having a hard time trying to print only the first occurrence between 2 idenicale strings.
for the following output:
please
help
me im a
noob
please
im a noob
help me
noob
please
help
me im a
noob
please
im a noob
help me
noob (3 Replies)
Hello all,
I need to filter a dataframe composed of several columns of data to remove the duplicates according to one of the columns. I did it with pandas. In the main time, I need that the last column that contains all different data ( not redundant) is conserved in the output like this:
A ... (5 Replies)
Discussion started by: pedro88
5 Replies
LEARN ABOUT PHP
db2_fetch_object
DB2_FETCH_OBJECT(3) 1 DB2_FETCH_OBJECT(3)db2_fetch_object - Returns an object with properties representing columns in the fetched rowSYNOPSIS
object db2_fetch_object (resource $stmt, [int $row_number = -1])
DESCRIPTION
Returns an object in which each property represents a column returned in the row fetched from a result set.
PARAMETERS
o $stmt
- A valid stmt resource containing a result set.
o $row_number
- Requests a specific 1-indexed row from the result set. Passing this parameter results in a PHP warning if the result set uses a
forward-only cursor.
RETURN VALUES
Returns an object representing a single row in the result set. The properties of the object map to the names of the columns in the result
set.
The IBM DB2, Cloudscape, and Apache Derby database servers typically fold column names to upper-case, so the object properties will
reflect that case.
If your SELECT statement calls a scalar function to modify the value of a column, the database servers return the column number as the
name of the column in the result set. If you prefer a more descriptive column name and object property, you can use the AS clause to assign
a name to the column in the result set.
Returns FALSE if no row was retrieved.
EXAMPLES
Example #1
A db2_fetch_object(3) example
The following example issues a SELECT statement with a scalar function, RTRIM, that removes whitespace from the end of the column.
Rather than creating an object with the properties "BREED" and "2", we use the AS clause in the SELECT statement to assign the name
"name" to the modified column. The database server folds the column names to upper-case, resulting in an object with the properties
"BREED" and "NAME".
<?php
$conn = db2_connect($database, $user, $password);
$sql = "SELECT breed, RTRIM(name) AS name
FROM animals
WHERE id = ?";
if ($conn) {
$stmt = db2_prepare($conn, $sql);
db2_execute($stmt, array(0));
while ($pet = db2_fetch_object($stmt)) {
echo "Come here, {$pet->NAME}, my little {$pet->BREED}!";
}
db2_close($conn);
}
?>
The above example will output:
Come here, Pook, my little cat!
SEE ALSO db2_fetch_array(3), db2_fetch_assoc(3), db2_fetch_both(3), db2_fetch_row(3), db2_result(3).
PHP Documentation Group DB2_FETCH_OBJECT(3)