dtype
noun
say it: “DEE-type” /ˈdiˌtaɪp/
In pandas and NumPy, the kind of value a column or array holds, such as whole numbers, decimal numbers, text or dates.
What is a dtype in pandas?
A dtype, short for data type, is the kind of value every row of a pandas column holds: int64 for whole
numbers, float64 for numbers with decimals, str for text and datetime64 for dates. It decides what the column
can do: a str column of weights can't be averaged until it becomes numbers.
import pandas as pd
weights = pd.Series(["12 lbs", "5.5", "about 15"])
print(weights.dtype) # str: text, not numbers
print(pd.Series([21, 25, 18]).dtype) # int64
In a sentence
- “The weight column's dtype was str, so its mean couldn't be worked out.”
- “info() lists the dtype of every column.”
Level: Journeyman · More Python terms at this level
Updated