Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

function
pandas
data science
communitycreator

How to show the NumPy representation of a dataframe in Pandas

Onyejiaku Theophilus Chidalu

Overview

In Pandas, the DataFrame.values attribute is used to return the NumPy representation of a given dataframe.

Syntax

DataFrame.values 
Syntax for the DataFrame.values attribute

Parameters

This attribute takes no parameter value.

Return value

This attribute returns the values of a given dataframe.

Example

import pandas as pd

# creating a dataframe
df = pd.DataFrame({'AGE':    [ 20,  29],
                   'HEIGHT': [94, 170],
                   'WEIGHT': [80, 115]})
# implementing the dataframe.values() function 
print(df.values)
Implementing the DataFrame.values() function

Explanation

  • Line 1: We import the pandas module.
  • Lines 4–6-: We create a dataframe, df.
  • Line 10: We implement the DataFrame.values attribute to obtain the NumPy values of df. Next, we print the value to the console.

RELATED TAGS

function
pandas
data science
communitycreator

CONTRIBUTOR

Onyejiaku Theophilus Chidalu
RELATED COURSES

View all Courses

Keep Exploring