liveBook · Manning

Data type

As explained in Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI

A classification that specifies the kind of values a data field can contain.

A data type classifies the values a field can contain. In tabular data, every column shares a common type, such as integer, string, or floating-point number, helping describe and handle its values appropriately. section 1.1 section 2.1.3

Common tabular column types include:

  • Numeric values, represented by integers or floating-point numbers; continuous measurements such as units per US dollar use real numbers. section 1.1 section 2.1.3
  • Categorical values, drawn from a finite set such as country, currency name, gender, or education level. section 1.1 section 2.1.3
  • Free-form text, which can contain varied values or no value, as with currency nicknames. section 1.1
  • Date, datetime, and boolean values, which can represent temporal fields or binary features. section 2.1.3

A small customer dataset

A pandas DataFrame can combine gender and education_level categories with integer age and numeric income. Four labeled rows represent Bob, Alice, Charlie, and Emily; selecting Alice returns all four typed attributes. section 2.1.3

Listing 2.1 Creating a simple tabular dataset
import pandas as pd
data = {'gender': ['male', 'female', 'male', 'female'],
        'age': [25, 30, 27, 29],
        'education_level': ['Bachelor', 'Master', 'Bachelor', 'PhD'],
        'income': [50000, 60000, 55000, 70000]}              #1
index = [ 'Bob ', 'Alice', 'Charlie', 'Emily']               #2
df = pd.DataFrame(data, index=index)                         #3
print(df)
print(df.iloc[1])                                            #4
print(df.loc['Alice'])                                       #5

Inspect a runnable pandas example that creates a mixed-type DataFrame and accesses rows by index and label. section 2.1.3

How Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI covers it

How deep it goes
Defines common field types and illustrates mixed-type DataFrame construction, but stops short of detailed type conversion or validation procedures.
Examples
Uses a currency table and a four-person pandas dataset containing gender, age, education level, and income.
What you can do after
Apply data types via pandas by creating, labeling, selecting, and managing mixed-type tabular DataFrames.
How it connects
Connects data types with tabular data, categorical columns, continuous columns, pandas DataFrames, and feature representation.

Also explained in

Compare how 18 books explain data type →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI. The section links point to the parts of the book it draws on.