Search this site
Embedded Files
AIMD GPDS Courses
  • Home
  • Courses
  • Contact
AIMD GPDS Courses
  • Home
  • Courses
  • Contact
  • More
    • Home
    • Courses
    • Contact

日本語  ❯

Lesson 1    ❮    Lesson List    ❮    Top Page

1.1  DataFrame

❯  1.2  Data Types Conversion

1.3  Rows Selection

1.4  Columns Selection

⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺
EXPECTED COMPLETION TIME
❲▹❳  Video   5m 37s
☷  Interactive readings   5m

Types of Data

pandas does not broadly classify data as either continuous or categorical. 

The following table contains all pandas data types, with their string equivalents, and some notes on each type:

Common data
type name

Boolean
Integer
Float
Complex
Object
Datetime
Timedelta
Categorical
NumPy/pandas
object

np.bool
np.int
np.float
np.complex
np.object
np.datetime64
np.timedelta64
pd.Categorical
Pandas string
name

bool
int
float
complex
O, object
datetime64
timedelta64
category

Converting from numerical to categorical

To convert numerical to categorical, the astype method can be used. This method can cast a pandas object to a specified dtype.

> Note that the column facenumber_in_posters only consists of integer but pandas read it as float64. This is because the column has some missing values.  Column with missing values cannot be directly converted to integer.

Converting from categorical to numerical

To convert categorical to numerical, the get_dummies method can be used. It will convert the categorical column into a 0-1 columns called dummy variables. 

> It is possible to perform get_dummies for numerical column. It will generate a lot of columns and those might not be too useful.
©2023. All rights reserved.  Samy Baladram,
Graduate Program in Data Science - GSIS - Tohoku University
Google Sites
Report abuse
Page details
Page updated
Google Sites
Report abuse