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