Question: we have not discussed. - convert _ col _ to _ type ( table , col _ index, type _ converter ) This function takes

we have not discussed.
- convert_col_to_type(table, col_index, type_converter)
This function takes in table, the index of a column col_index, and a function which will convert to the desired type (for example, type_converter could be the function int to convert into ints or the function float to convert into floats) and will modify the table in place such that the elements of column of index col_index will be converted to the desired type, and the function does not return anything.
Note: Beware that the header row should not be converted. Also any element that is an empty string should also not be converted. So for example, if the column is ['Age','5','24','7',''] and type_converter is int, then the column should be converted to ['Age',5,24,7,''].
- select_col_by_index(table, index)
This function returns a copy the index \({}^{\text {th }}\) column of table.
- select_row_by_index(table, index)
This function returns a copy the index \({}^{t h}\) row of table. - select_row_by_index(table, index)
This function returns a copy the index \({}^{t h}\) row of table.
- get_index_of_label(header, label)
This function takes in the header of a table (i.e. a list with the names of the columns) and a label (i.e. the name of a desired column), and returns the index of the column with that label. Raise a value error if the label is not found. Note that the starter code docstring for this function gives an example of how to do this. - select_col_by_label(table, label)
This function takes in a table and a column label (i.e. the name of the desired column) and returns a copy of that column as a list.
Note: This function can make use of get_index_of_label and select_col_by_index.
- transpose_table(table)
This function return a transpose of the table. In other words, it returns a table whose rows are the columns of the argument table.
e.g. if table \(=[[1,2,3],[4,5,6]]\), then this function would return [[1,4],[2,5],[3,6]].
This function is not used by the other functions, but it is a good exercise. Also, the underlying implementation of pandas does make heavy use of such a function since it often works on the transposed table, for technical reasons having to do with memory layout.
- filter_table_by_value(table, column_label, value)
This function should return a copy of a subset of table which includes the header of table and only the rows such that their value in the column identified by column_label is equal to the value argument.
For example if table =[['A','B'],[0, True],[4, False],[2, True]], then filter_table_by_value(table,'B', False) should return: [['A','B'],[4, False]]. Note that this function has an argument table, but the function should not be specific to the table of chemical elements. - periodic_table_to_str()
This function uses the previous functions to return a string representation of a periodic table where the None's are replaced by spaces, the elements are separated by Tabs, and both the Lanthanide and Actinide Series of elements are there printed below the rest of the periodic table.
Most of the code of this function is given to you. The code builds a string representation of the 7 periods (rows) of the periodic table. To complete this function, you will need to use your filter_table_by_value function to extract the Lanthanides and Actinides from the table returned by elements_table = import_csv_file('elements.csv'). Your task is to add the two rows which contain the Lanthanides (lan_series) and the Actinides (act_series), with the format shown in the docstring. You can filter out these two series using filter_table_by_value after noting they have '' as values in the column 'Group'. You can then separate the Lanthanides which have value 6 in the column 'Period' from the Actinides which have value 7. Here is the only place where we allow hard-coding: you can hard-code the values 6 and 7 here.
we have not discussed. - convert _ col _ to _

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 Programming Questions!