In the pandas Python library, we can use the DataFrame.info() function to get the summary of a DataFrame.
import pandas df = pandas.read_csv("iris.csv") print(df.info())
Here, we are first reading the CSV file “iris.csv” and creating the DataFrame df. After that, we are using the DataFrame.info() function to get the summary of the dataset.
The output of the above program will be:
RangeIndex: 150 entries, 0 to 149 Data columns (total 5 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 sepal_length 150 non-null float64 1 sepal_width 150 non-null float64 2 petal_length 150 non-null float64 3 petal_width 150 non-null float64 4 species 150 non-null object dtypes: float64(4), object(1) memory usage: 6.0+ KB None
Here, the range index shows the range of the indexes of the rows. And then, we get the details about the columns of the dataset. As we can see there are 5 columns in the dataset. The first four columns contain floating point values and the last column contains objects.
We can also see that all the columns contain 150 non-null values, where the total number of rows is also 150.






0 Comments