# Ceil and floor of the dataframe in Pandas Python – Round up and Truncate

## Ceil and floor of the dataframe in Pandas Python – Round up and Truncate

In this article, we will discuss getting the ceil and floor values of the Pandas Dataframe. First, Let’s create a dataframe.

Example:

 `# importing pandas and numpy` `import` `pandas as pd` `import` `numpy as np` `# Creating a DataFrame` `df ``=` `pd.DataFrame({``'Student Name'``: [``'Anuj'``, ``'Ajay'``, ``'Vivek'``,` `                                    ``'suraj'``, ``'tanishq'``, ``'vishal'``],` `                   ``'Marks'``: [``55.3``, ``82.76``, ``95.23``, ``98.12``,` `                             ``95.78``, ``90.56``]})` `df`

Output:

### Getting the Ceil Value

We can get the ceil value using the ceil() function. Ceil() is basically used to round up the values specified in it. It rounds up the value to the nearest greater integer.

Example:

 `# using np.ceil to round to` `# nearest greater integer for` `# 'Marks'` `df[``'Marks'``] ``=` `df[``'Marks'``].``apply``(np.ceil)` `df`

Output:

### Getting the floor value

We can get the floor value using the floor() function. Floor() is basically used to truncate the values. Basically, it truncates the values to their nearest smaller integer.

Example:

 `# using np.floor to` `# truncate the 'Marks' column` `df[``'Marks'``] ``=` `df[``'Marks'``].``apply``(np.floor)` `df`

Output:

### Getting the round off value

round() is also used in this purpose only as it rounds off the value according to their decimal digits. Here we can give that to how many decimal places we have to round off our data.

Example:

 `# using round() to round up or` `# down acc. to their decimal digits` `df[``'Marks'``] ``=` `df[``'Marks'``].``round``(decimals``=``1``)` `df`

Output:

Last Updated on October 18, 2021 by admin

## Pandas Series.str.slice()Pandas Series.str.slice()

Python Pandas Series.str.slice() Pandas str.slice() method is used to slice substrings from a string present in Pandas

## Get a list of a particular column values of a Pandas DataFrameGet a list of a particular column values of a Pandas DataFrame

Get a list of a particular column values of a Pandas DataFrame   In this

## Creating a Pandas Series from ListsCreating a Pandas Series from Lists

Creating a Pandas Series from Lists   A Series is a one-dimensional labeled array capable

## How to Convert Index to Column in Pandas Dataframe?How to Convert Index to Column in Pandas Dataframe?

How to Convert Index to Column in Pandas Dataframe? Pandas is a powerful tool which is

## How to create a table with clickable hyperlink to a local file in Pandas?How to create a table with clickable hyperlink to a local file in Pandas?

How to create a table with clickable hyperlink to a local file in Pandas? If

## Python – Convert an HTML table into excelPython – Convert an HTML table into excel

Python – Convert an HTML table into excel MS Excel is a powerful tool for

## How to reshape Pandas Series?How to reshape Pandas Series?

How to reshape Pandas Series? In this article, we will see how to reshaping Pandas Series.

## How to read all CSV files in a folder in Pandas?How to read all CSV files in a folder in Pandas?

How to read all CSV files in a folder in Pandas? In this article, we