I'm doing a training task in Jupyter notebook and I'm writing the following code to count the number of items in the "Trans_id" column of the table:
df = pd.read_csv('Xyz.csv')
num_trans = df["trans_id"].value_counts()
num_trans
However I'm getting the following error:
Your answer has the type
<class 'pandas.core.series.Series'>
for thenum_trans
variable but we expected anint
orfloat
. Double check your code.
I tried to solve it the following way but it didn't work:
df = pd.read_csv('Xyz.csv')
num_trans = df["trans_id"].value_counts()
num_trans.to_float()
num_trans
How would you recommend me to solve it? Thank you!!!