In: Computer Science
Assume you have the Pandas DataFrame data, with the following contents:
our_columns_name column_A column_B column_C column_D column_E
our_index_name
row_name_0 9 93 71 Hello 102
row_name_1 28 64 37 my 92
row_name_2 13 91 93 name 104
row_name_3 45 29 54 is 74
row_name_4 0 36 31 Jason 36
Each column has a dtype (data type). Which of the following could be set of dtypes for this DataFrame?
Hint 1: None of the numeric values shows a decimal point. (A float shows a decimal point, while an int does not. For example, 3. is a float, while 3 is an int.)
Hint 2: A column that has strings has a dtype of object, not str.
You can create the DataFrame above with this code:
data = pd.DataFrame({'column_A': {'row_name_0': 9,
'row_name_1': 28,
'row_name_2': 13,
'row_name_3': 45,
'row_name_4': 0},
'column_B': {'row_name_0': 93,
'row_name_1': 64,
'row_name_2': 91,
'row_name_3': 29,
'row_name_4': 36},
'column_C': {'row_name_0': 71,
'row_name_1': 37,
'row_name_2': 93,
'row_name_3': 54,
'row_name_4': 31},
'column_D': {'row_name_0': 'Hello',
'row_name_1': 'my',
'row_name_2': 'name',
'row_name_3': 'is',
'row_name_4': 'Jason'},
'column_E': {'row_name_0': 102,
'row_name_1': 92,
'row_name_2': 104,
'row_name_3': 74,
'row_name_4': 36}})
column_A int64
column_B float64
column_C float64
column_D object
column_E int64
column_A int64
column_B int32
column_C int32
column_D int64
column_E int64
column_A int64
column_B int64
column_C int64
column_D object
column_E int64
#option c is correct which is
column_A int64
column_B int64
column_C int64
column_D object
column_E int64
#source code in python:
import pandas as pd
data = pd.DataFrame({'column_A': {'row_name_0': 9,
'row_name_1': 28,
'row_name_2': 13,
'row_name_3': 45,
'row_name_4': 0},
'column_B': {'row_name_0': 93,
'row_name_1': 64,
'row_name_2': 91,
'row_name_3': 29,
'row_name_4': 36},
'column_C': {'row_name_0': 71,
'row_name_1': 37,
'row_name_2': 93,
'row_name_3': 54,
'row_name_4': 31},
'column_D': {'row_name_0': 'Hello',
'row_name_1': 'my',
'row_name_2': 'name',
'row_name_3': 'is',
'row_name_4': 'Jason'},
'column_E': {'row_name_0': 102,
'row_name_1': 92,
'row_name_2': 104,
'row_name_3': 74,
'row_name_4': 36}})
print(data.dtypes)
#output:
#if you have any doubt comment below...if you like give thumbs up.....