Questions tagged [array-column]

The array_column() return the values from a single column in the input array.

$records = array(
    array(
        'id' => 2135,
        'first_name' => 'John',
        'last_name' => 'Doe',
    ),
    array(
        'id' => 3245,
        'first_name' => 'Sally',
        'last_name' => 'Smith',
    )
);
$first_names = array_column($records, 'first_name');
print_r($first_names);

The above example will output:

Array
(
    [0] => John
    [1] => Sally
)
102 questions
2
votes
1 answer

SparkR, split a column of nested JSON strings into columns

I am coming from R, new to SparkR, and trying to split a SparkDataFrame column of JSON strings into respective columns. The columns in the Spark DataFrame are arrays with a schema like this: > printSchema(tst) root |-- FromStation: array (nullable…
nate
  • 1,172
  • 1
  • 11
  • 26
2
votes
1 answer

Isolate an array column containing indexed rows of data, then flatten/merge to form an array of rows

situation I have an array result returned from an Database call. In the example below, it fetches many Genres which can have many books. Using a join, the query pulls the books from each genre at the same time. Here is a hypothetical result…
Simon
  • 816
  • 2
  • 7
  • 16
1
vote
1 answer

Using array_column() in nested multi dimensional array to access dynamic indexes and values

I have this nested multidimensional array for orders [ [ 'created_at' => 1991, 'updated_at' => 1992, 'customer_name' => 'john doe', 'line_items' => [ [ 'name' => 'Hello world poduct', …
John
  • 51
  • 5
1
vote
1 answer

What is PostgreSQL Array Column equivalent in Synapse SQL?

I have a table in PostgreSQL that has array column like abc_id varchar[](1) and it has data in it like {A,B,C}. I want to create that table in Synapse SQL how can I create array columns is it possible?
1
vote
2 answers

Matching vocabulary elements to indices from LDA Model using PySpark

I'd like to take a Spark LDA Model's term indices from the .describeTopics() output and match them to the appropriate term in the count vectorizer's vocabulary. Here is the point of friction: terms = ['fuzzy', 'wuzzy', 'bear', 'seashells', 'chuck',…
1
vote
3 answers

Get column values from third level of a multidimensional array

I want to get all of the values from an array with 3 levels where the key is age. How can I extract a column of data from a three dimensional array without using a foreach() loop? My input array: $description = [ [ ['name' => 'john',…
manishk
  • 526
  • 8
  • 26
1
vote
3 answers

Populate option tags with data- attributes using a multidimensional array

I have a json file that looks something like this: { "world": { "france": { "city": { "city_1": { "name": "paris", "titre": "lorem ipsum" }, …
Creatz
  • 49
  • 5
1
vote
5 answers

Partially-flattening a multi-dimensional array

What would be a good way to transform an array that looks like: Array ( [0] = Array ( [0] = Array ( [key] = val [key2] = val2 ) ) [1] = Array ( [0] =…
mike23
  • 11
  • 1
1
vote
1 answer

array_column doesn't work with first key in nested array

I have a nested array like so $array = array( [2] => array( [5] => array( [7] => array( [46] => array() ) ), [108] => array() ), [14] => array(), [8] => array( [72] => array() …
Leopold
  • 27
  • 5
1
vote
4 answers

How to drop pandas row based on values of array column?

I have the following dataframe in pandas: id name categoryids shops 5 239 Boulanger [5] 152 3 196 Bouygues Telecom [5] 500 4 122 Darty [5,3] 363 1 311 Electro…
jcf
  • 602
  • 1
  • 6
  • 26
1
vote
1 answer

Get multi column from array php, Alternate of array_column

I have used this function to get multi column from array. Alternate of array_column. I have created this function as array_column not work according my requirement. My Data $students = Array ( [0] => stdClass Object ( [id]…
1
vote
2 answers

Print unique values from an array column as a comma-separated string

I want to print all unique Department values from a multidimensional array as a comma-separated string, but not all rows have a Department value. The boiled down version of my array looks like this: $employee = [ ["employee_id" => 1,…
1
vote
2 answers

First value duplicate in array while using array_search function

I am trying to remove duplicates from two dimensional array based on client ID. The script removes all duplicates EXCEPT the first value, first client. I have tried few more ways of comparing result from array_search to different values, trying to…
Wesan
  • 57
  • 2
  • 7
1
vote
2 answers

How to sort the column sequence of 2D array in AutoIt

Summary: I'm looking for a proper way to sort a 2D (multidimensional) array by the column sequence in AutoIt. I'm quite familiar with AutoIt and there is the _ArraySort function which provides a sorting by columns which leads to sorted rows. But…
user10815634
1
vote
1 answer

What is the equivalent of array_column in python3

I have a list of dictionary and I want to get only a specific item from each dictionary. My data pattern is: data = [ { "_id": "uuid", "_index": "my_index", "_score": 1, "_source": { "id" : 1, …
MH2K9
  • 11,951
  • 7
  • 32
  • 49