Question: For a collection of things in the world, an array is useful for describing a single attribute of each thing. For example, among the collection

For a collection of things in the world, an array is useful for describing a single attribute of each thing. For example, among the collection of US States, an array could describe the land area of each. Tables extend this idea by describing multiple attributes for each element of a collection.
In most data science applications, we have data about many entities, but we also have several kinds of data about each entity.
For example, in the cell below we have two arrays. The first one contains the world population in each year (estimated by the US Census Bureau), and the second contains the years themselves. These elements are in order, so the year and the world population for that year have the same index in their corresponding arrays.
population_amounts = Table.read_table("world_population.csv").column("Population")
years = np.arange(1950,2016,1)
print("Population column:", population_amounts)
print("Years column:", years)
Population column: [255762865425949398772636772306268205338927302281042782098943
283529967328913497172948137248300071659330430015083083966929
314009321732098278823281201306335042579334206779233490333715
356231382236371590503712697742379032694838665686533942096442
401660881340890832334160185010423208457843041057534379013942
445136273545344101254614566561469573674347745693914856462699
494057123250272004925114557167520144011052889559345371585922
545613627855382683165618682132569920298557794405935857972543
593521324860120749226088571383616521924762420163486318590956
639569950964730447326551263534662991375967090497806788214394
686633235869440555837022349283710102789571787228937256490011]
Years column: [195019511952195319541955195619571958195919601961196219631964
196519661967196819691970197119721973197419751976197719781979
198019811982198319841985198619871988198919901991199219931994
199519961997199819992000200120022003200420052006200720082009
201020112012201320142015]
Suppose we want to answer this question:
When did world population cross 6 billion?
You could technically answer this question just from staring at the arrays, but it's a bit convoluted, since you would have to count the position where the population first crossed 6 billion, then find the corresponding element in the years array. In cases like these, it might be easier to put the data into a Table, a two-dimensional type of dataset.
The expression below:
creates an empty table using the expression Table(),
adds two columns to the table by calling with_columns with four arguments (column and data for each),
assigns the result to the name population, and finally
evaluates population so that we can see the table.
The strings "Year" and "Population" are column labels that we have chosen. Ther names population_amounts and years were assigned above to two arrays of the same length. The function with_columns (you can find the documentation here) takes in alternating strings (to represent column labels) and arrays (representing the data in those columns), which are all separated by commas. Tip: Both population_amounts and years need the same number of data points or an error will be returned on attempting to construct the table.
population = Table().with_columns(
"Population", population_amounts,
"Year", years
)
population
Population Year
25576286541950
25949398771951
26367723061952
26820533891953
27302281041954
27820989431955
28352996731956
28913497171957
29481372481958
30007165931959
...(56 rows omitted)
Now the data are all together in a single table! It's much easier to parse this data--if you need to know what the population was in 1959, for example, you can tell from a single glance. We'll revisit this table later.
Question 1.
From the example in the cell above, identify the variables or data types for each of the following: which variable contains the table? which variable contains an array? On the right of the equals sign provide the correct variable name. Note that in the cell above we defined one table, which contains two arrays, so you can pick either array variable for your answer.
table_var =...
array_var =...

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!