1.Working with CSV files using a dictionary structure for your reader is more resistant to change in the data files (like data rows being re-arranged).
True
False
2.When passing a dictionary to table_print as the data values, we need to use the .[blank]() method.
Answers:
(1) False
Explanation - When using a dictionary to read a csv file, the header of the csv file is stored as dictionary key and the data of the csv files are stored as values in the dictionary.
So one can use dictionary operations to access these rows and data and rearrange them accordingly.
(2) When passing a dictionary to table_print as the data values we need to use the .values() method.
Explanation - The values() method is used to access all the values that are stored in the dictionary. You can either access values of the whole dictionary or a particular column.
For example:
import pandas as pd
dicti = pd.read_csv('iris.csv',header=0,index_col = None,squeeze = True).to_dict()
for x in dicti['species'].values():
print(x)
Get Answers For Free
Most questions answered within 1 hours.