Skip to content

Latest commit

 

History

History
86 lines (62 loc) · 2.46 KB

Attribute.md

File metadata and controls

86 lines (62 loc) · 2.46 KB

Attribute

Attribute

Description

DataFrame.index Row labels of DataFrame
DataFrame.columns Column labels of DataFrame
DataFrame.axes Label values of rows and columns in the DataFrame
DataFrame.dtypes Data types for each column of DataFrame
DataFrame.size Total number of elements in a DataFrame
DataFrame.shape Dimensions of DataFrame ( Number of rows, Number of columns )
DataFrame.ndim No. of Dimensions ( 1D, 2D, 3D )
DataFrame.empty Check whether DataFrame is empty or not
DataFrame.T Change the rows into columns and columns into rows
DataFrame.values Values of DataFrame in the form of NumPy array

DataFrame.index

print(df.index)

# By default it automatically creates a RangeIndex(start=0, stop=len(df), step=1)
# We can manually add index by passing list to index parameter i.e. index = [1, 2, 3]
# We can also set some existing column as an index i.e index = 'City'

DataFrame.columns

print(df.columns)

DataFrame.axes

print(df.axes)

DataFrame.dtypes

print(df.dtypes)

DataFrame.size

print(df.size)

DataFrame.shape

# Dimensions of the dataframe:
print(df.shape)

# Extract only the total number of rows in a dataframe:
print(df.shape[0])

# Extract only the total number of columns in a dataframe:
print(df.shape[1])

DataFrame.ndim

print(df.ndim)

DataFrame.empty

print(df.empty)

DataFrame.T

print(df.T)

DataFrame.values

print(df.values)