What Is Data Frame In Python
A Data frame is a two-dimensional data structure who contains different kind of data in tabular format.
Features of DataFrame
1.It contains different kind of data
2.Data frame is mutable that means you can change the data frame
3.Labeled axes (rows and columns)
4.Arithmetic operation can be performed on data of Data Frame
Different Types Of Inbuilt Functions In Data Frame Python
index(): Return the index (row level) of the dataframe
axes(): Return the list which represents the axes of the dataframe
insert(): Inserts a column into a DataFrame.
add(): Returns the addition of DataFrame and other, element-wise (binary operator add)
sub(): Returns subtraction of DataFrame and other, element-wise (binary operator sub)
mul(): Returns multiplication of DataFrame and other, element-wise (binary operator mul)
div(): Returns floating division of DataFrame and other, element-wise (binary operator truediv)
dtypes(): Returns a Series with the data type of each column.
unique(): Extracts the unique values in the DataFrame.
loc[]: Retrieves rows based on an index label.
drop():Delete rows or columns from a DataFrame.
pop():Delete rows or columns from a DataFrame.
columns():Alternative attribute to change the column name.
dropna():Allows the user to analyze and drop Rows/Columns with Null values in different ways.
fillna():Manages and lets the user replace NaN values with some value of their own.
How To Load Data Into Data Frame Using Panda
The most common way of storing huge amount of data to use it in a dataframe is CSV file format.
To do the data anlaytics with CSV file data you have to first import the CSV files using Panad Dataframe.
To import the CSV files into Panda Dataframe you have to import Panda libraries
Let's look at the below example how we can import CSV file in a Panda Dataframe Object
Here the csv file name is data.csv
import pandas as pd
df = pd.read_csv('data.csv')
print(df.to_string())
Here we are using to_string function to print the entire dataframe
Duration Pulse Maxpulse Calories
0 60 110 130 409.1
1 60 117 145 479.0
2 60 103 135 340.0
3 45 109 175 282.4
4 45 117 148 406.0
5 60 102 127 300.5
Comments
Post a Comment
souvikdutta.aec@gmail.com