values

This attribute is used to represent the values/data of dataframe in NumPy array form.

Syntax: dataframe_name.values

Python3




# Python program to implement values
# attribute in a dataframe object
import pandas as pd
 
# Creating a 2D dictionary having values as
# dictionary object
dict = {"Sales": {'Name': 'Shyam',
                  'Age': 23,
                  'Gender': 'Male'},
        "Marketing": {'Name': 'Neha',
                      'Age': 22,
                      'Gender': 'Female'}}
 
# Creating a data frame object
data_frame = pd.DataFrame(dict)
 
# printing this data frame on output screen
display(data_frame)
 
# Implementing values attribute for this data frame
print("NumPy Array form of this DataFrame is:")
print(data_frame.values)


Output:

In this program, we have made a DataFrame from a 2D dictionary having values as dictionary object and then printed this DataFrame on the output screen At the end of the program, we have implemented the “values” attribute as print(data_frame.values) to print all the data of this DataFrame in the form of NumPy array.



Dataframe Attributes in Python Pandas

In this article, we will discuss the different attributes of a dataframe. Attributes are the properties of a DataFrame that can be used to fetch data or any information related to a particular dataframe.

The syntax of writing an attribute is:

DataFrame_name.attribute

These are the attributes of the dataframe:

  • index
  • columns
  • axes
  • dtypes
  • size
  • shape
  • ndim
  • empty
  • T
  • values

Similar Reads

index

There are two types of index in a DataFrame one is the row index and the other is the column index. The index attribute is used to display the row labels of a data frame object. The row labels can be of 0,1,2,3,… form and can be of names....

columns

...

axes

...

dtypes

This attribute is used to fetch the label values for columns present in a particular data frame....

size

...

shape

This attribute is used when we want to fetch the values of all row labels and all column labels at a time....

ndim

...

empty

The purpose of this attribute is to display the data type for each column of a particular dataframe....

T (Transpose)

...

values

This attribute is used to display the total number of elements or items present in a data frame....