You are on page 1of 45

DataFrame

 DataFrame is a Two-Dimensional labelled data structure like a table of MySQL.


 It contains rows and columns, i.e. has both a row and column index.
 DataFrame object can store 2D heterogeneous data.

FEATURES OF DataFrame

 Columns can be of different types of data such as numeric, string, Boolean etc.
 Size of data is mutable. ( rows / columns can be increased or decreased )
 DataFrame values / data are mutable ( can be changed any time )
 Labelled axes ( both row and column have index )
 Arithmetic operations on rows and columns. . Column Indexes
 Indexes may constitute of numbers / strings or letters

Name Class Section Roll_No

Row Indexes
0 Rahul X A 25
1 Vijay X B 34
2 Mukesh X A 20
3 Meghna X A 45
CREATION OF DataFrame

 Syntax: –

pandas.DataFrame(data, index, columns)

data Data can be ndarray, series, list, dictionary, another DataFrame.


Row levels (Row index values). If indexes are not specified, by default takes values from 0 to n-1, where
index
n is total number of rows.
Column levels (Column index values). If indexes are not specified, by default takes values from 0 to n-1,
column
where n is total number of columns.

(PRADEEP IP CLASSROOM) DataFrame Notes : 1 | P a g e


 CREATING AN EMPTY DataFrame

 DataFrame() method is used to create an empty DataFrame.


 print (DataFrame_name/object) to display the DataFrame.
 Syntax:
import pandas as pd
DataFrame_object = pd.DataFrame()

 Example:

/// columns and index are empty as no arguments has been passed to DataFrame() method ///

 DataFrame can be created using:  Lists


 Series
 Dictionary
 NumPY ndarray

 CREATING DataFrame FROM LISTS

 List is passed as an argument to DataFrame() method and gets converted into DataFrame elements.
 Columns and Index are automatically created. By default starts from 0 if no index values are provided.

(PRADEEP IP CLASSROOM) DataFrame Notes : 2 | P a g e


 Example:

Column label

Index

 CREATING DataFrame FROM NESTED LISTS


 Example:

(PRADEEP IP CLASSROOM) DataFrame Notes : 3 | P a g e


 CREATING DataFrame FROM SERIES

 CREATING DataFrame FROM SINGLE SERIES


 When a single series is used to create a DataFrame, the elements of the series becomes column in the DataFrame.

 CREATING DataFrame FROM MULTIPLE SERIES


 When two or more series are provided as argument to a DataFrame, the elements of the series becomes the rows of the
resultant DataFrame.

(PRADEEP IP CLASSROOM) DataFrame Notes : 4 | P a g e


 BEST WAY TO CONVERT MULTIPLE SERIES INTO DATAFRAME
 To create a resultant dataframe from multiple series, Create Series using dictionary and convert the created series into a
dictionary which is passed as an argument to the DataFrame() method along with the column labels.
 Example:

 CREATING DataFrame FROM DICTIONARY

 Dictionary can be passed as an input data to create a dataframe.


 The dictionary key by default are taken as column names.
 Ways to create a DataFrame using dictionary are:
 Dictionary of list
 Dictionary of series
 List of dictionary

 CREATING A DataFrame USING DICTIONARY OF LISTS ( Lists inside Dictionary  DataFrame )


 Create a dictionary of lists with its elements. All the keys of the dictionary becomes the column names of the DataFrame and
the Values from lists in dictionary becomes rows of dataframe.

(PRADEEP IP CLASSROOM) DataFrame Notes : 5 | P a g e


 CREATING A DataFrame USING DICTIONARY OF SERIES ( Series  Dictionary  DataFrame )
 A dictionary of series can also be used to create a DataFrame.

(PRADEEP IP CLASSROOM) DataFrame Notes : 6 | P a g e


 Can also create a DataFrame from a dictionary of series by directly passing the values to the dictionary using Series() method.

 CREATING A DataFrame USING LIST OF DICTIONARY ( Dictionaries inside List  DataFrame )


 Creating a DataFrame using list of multiple dictionary. Dictionary keys are converted into columns names and values as rows of
DataFrame.

/// NaN (Not a Number) is automatically added for missing values ///

(PRADEEP IP CLASSROOM) DataFrame Notes : 7 | P a g e


 CREATING A DataFrame USING NUMPY NDARRAY

SORTING DATA IN DataFrame

 sort_Values()  Used to sort data present inside the DataFrame.


 Syntax:
DataFrame_Object.sort_Values(by=[Column_Name] , ascending=True/False)

 Have two arguments:


o Sorting field ( Column Name ). by keyword defines the name of the column based on which the data is to be
sorted.
o Order of Sorting ( ascending = True / False )
 By default data are sorted in ascending order.
 Ascending=True ( Data sorted in ascending order ), Ascending=False ( Data sorted in descending order )

(PRADEEP IP CLASSROOM) DataFrame Notes : 8 | P a g e


(PRADEEP IP CLASSROOM) DataFrame Notes : 9 | P a g e
ADDING A NEW ROW IN DataFrame

 loc[] method is used to add new row to a DataFrame.


 Syntax:
DataFrame_object.loc[index] = new_value(s)

 Example:

 Cannot use this method to add a row of data with already existing (duplicate) index value (label). In such case, a row with this
index label will be updated / modified.
(PRADEEP IP CLASSROOM) DataFrame Notes : 10 | P a g e
 Adding a row with lesser values than the number of column in the DataFrame it will results in a ValueError.
 DataFrame.loc[] method can be used to change the data values of a row to a particular value.
 Example:

 SETTING / CHANGING ALL VALUES OF A DataFrame TO A PARTICULAR VALUE


 Syntax:
DataFrame_object[:]= any particular value

 Example:

(PRADEEP IP CLASSROOM) DataFrame Notes : 11 | P a g e


ADDING A NEW COLUMN IN DataFrame

 Syntax:
1
DataFrame_object[new column label] = new_value(s)
 Example:

 Assigning values to a new column label that does not exist will create a new column at the end.
 If the column already exists in the DataFrame then the existing column values are updated.
 We can change the data of entire column to a particular value in a DataFrame.
 Syntax:
DataFrame_object[column_label] = new_value

(PRADEEP IP CLASSROOM) DataFrame Notes : 12 | P a g e


 CREATING A NEW COLUMN USING insert() METHOD.

 By using insert() function, we can add a new column to the existing DataFrame at any position / column index.
 Syntax:

DataFrame_object.insert(n, new_column_name,[data], allow_dupliactes=False)

n : index of the column where the new column is to be inserted


new_column_name : new column to be inserted
[data] : lists of values to be added to the new column

 Example:

(PRADEEP IP CLASSROOM) DataFrame Notes : 13 | P a g e


DELETING ROWS AND COLUMNS FROM A DataFrame
 drop() method is used to delete rows and columns from a DataFrame.
 Syntax:
DataFrame_object.drop(labels, axis=0/1, inplace=True)

labels : name of the labels to be dropped


axis : axis 1 means column / axis 0 means row

(PRADEEP IP CLASSROOM) DataFrame Notes : 14 | P a g e


 If the DataFrame has more than one row / column with the same label, the drop() method will delete all the matching rows /
columns from it.

 USING THE del KEYWORD


 It will delete the entire column and its contains from the DataFrame.
 Syntax:
del DataFrame_object [ column_label ]

 USING THE pop() METHOD

 It will delete the column from a DataFrame by providing the name of the column as an argument. It will return the deleted
column along with its value.

(PRADEEP IP CLASSROOM) DataFrame Notes : 15 | P a g e


 Syntax:
DataFrame_object.pop( column_label )

RENAMING COLUMN NAME IN DataFrame

 SYNTAX TO CHANGE THE NAME OF A SINGLE COLUMN:

DataFrame_object.columns=[new_column_name]
(PRADEEP IP CLASSROOM) DataFrame Notes : 16 | P a g e
 SYNTAX TO CHANGE THE NAME OF MULTIPLE COLUMNS:

 Using rename() function


 Used to change names of specific columns as well as can be used to change as many column names we want.
 Syntax:

DataFrame_object.rename(columns=d, inplace=True)

d : d is a dictionary and the keys the columns to change and the values are the new names for these columns.
inplace = True : attribute of rename() to change column names in place.

 Example:
(PRADEEP IP CLASSROOM) DataFrame Notes : 17 | P a g e
RENAMING ROWS NAME IN DataFrame

 Using rename() function


 Used to change names of specific row as well as can be used to change as many rows names we want.
 Syntax:

dataframe_object.rename(index=d, inplace=True)

d : d is a dictionary and the keys the index to change and the values are the new names for these indexes.
inplace=True : attribute of rename() to change row names in place.

(PRADEEP IP CLASSROOM) DataFrame Notes : 18 | P a g e


 Example:

RENAMING ROWS / COLUMNS NAME USING AXIS ATTRIBUTE OF RENAME FUNCTION IN DataFrame

 Syntax:

dataframe_object.rename(d, axis=rows / columns, inplace=True)

d : d is a dictionary and the keys the columns / rows to change and the values are the new names for these columns / rows.
axis : can be ‘rows’ / ‘columns’ ( to rename either rows or columns )
inplace=True : attribute of rename() to change row names in place.

(PRADEEP IP CLASSROOM) DataFrame Notes : 19 | P a g e


RETRIEVING AND ACCESSING ROWS / COLUMNS FROM DataFrame

 ACCESSING DataFrame ELEMENT THROUGH INDEXING


 Two ways of indexing DataFrame:
 Label / Index based indexing
 Boolean indexing.

(PRADEEP IP CLASSROOM) DataFrame Notes : 20 | P a g e


 SELECTING OR ACCESSING ROWS / COLUMNS FROM A Dataframe USING iloc() and loc() method.

 loc() method – label based indexing


 Syntax:
DataFrame_object.loc[column_name / row_labels]

 When a single row label / column label is passed, it returns the row / column as series

(PRADEEP IP CLASSROOM) DataFrame Notes : 21 | P a g e


 To read more than one row / column from a DataFrame, a list of row labels / column names are used. [ [ ] ]

 iloc() method – index based indexing


 i stand for integer, which signifies that this command shall return a numeric values denoting the row and column range.
Displays all rows and columns of the DataFrame.
 Syntax:
DataFrame_object.iloc[row_indexes, column_indexes]

(PRADEEP IP CLASSROOM) DataFrame Notes : 22 | P a g e


Here, [:] - signifies all rows
[0,2] - indicates 0th and 2nd index columns

Here, [:] - signifies all rows


[1:4] - indicates range of columns

(PRADEEP IP CLASSROOM) DataFrame Notes : 23 | P a g e


 METHODS FOR SELECTING OR ACCESSING COLUMNS FROM A Dataframe

 Using the format of square brackets followed by the name of the column passed as a string value.
 Syntax:

DataFrame_object[column_name]

 Using dot notation.


 Syntax:
DataFrame_object.column_name

(PRADEEP IP CLASSROOM) DataFrame Notes : 24 | P a g e


 ACCESSING SINGLE VALUE FROM A Dataframe ( USE OF ATTRIBUTE .at AND .iat )
 iat[] – Index based access.
 Used to access the single values from DataFrame by their row and column number.
 Syntax:

DataFrame_object.iat[row_number, column_number]

row_number and column_number – indexing starts from 0 , so to select the values


from the nth row/column, the row/column number should be n-1.

 at[] – Label based access


 Used to access the single values from DataFrame by their row label and column name.
 Syntax:
DataFrame_object.at[row_label, column_name]

(PRADEEP IP CLASSROOM) DataFrame Notes : 25 | P a g e


 SELECTING OR ACCESSING ROWS / COLUMNS FROM A Dataframe USING SLICING
 Slicing allows retrieval of records as per the range defined with the DataFrame object.
 Used to select a subset of rows / columns from a DataFrame.

(PRADEEP IP CLASSROOM) DataFrame Notes : 26 | P a g e


 BOOLEAN INDEXING
 Boolean means a binary variable that can represent either of the two states – True (indicated by 1) or False (indicated by 0).
 In Boolean indexing uses actual values of the data in the dataframe rather than their row/column labels.
 The Boolean index of the Dataframe can be assessed by using the functions .loc[] and .iloc[]. The argument passed to
these functions is a Boolean value (True or False).

(PRADEEP IP CLASSROOM) DataFrame Notes : 27 | P a g e


 In order to access a DataFrame with a Boolean index, create a DataFrame in which index contains a Boolean values (‘True’ or
‘False’).
 Example

(PRADEEP IP CLASSROOM) DataFrame Notes : 28 | P a g e


 FILTERING ROWS IN DataFrame USING BOOLEAN VALUES

 In DataFrame, Boolean values (‘True’ or ‘False’) can be associated with indexes and can be used to filter rows using
DataFrame_object.loc[] method.
 Can use True for the rows to be shown and False for rows to be hide / omit.

HEAD() AND TAIL() FUNCTION

 head() function is used to get the first n rows from the object based on position. By default, it displays the first 5 rows.
 tail() function is used to get the last n rows from the object based on position. By default, it displays the last 5 rows.
 Syntax:

DataFrame_object.head / tail (n)

/// Here, n is the number of rows to be extracted

(PRADEEP IP CLASSROOM) DataFrame Notes : 29 | P a g e


(PRADEEP IP CLASSROOM) DataFrame Notes : 30 | P a g e
COMBINING / CONCATENATION / JOINING OF DATAFRAMES

 concat() function is used to combine or concatenate two or more DataFrames on the basis of rows (row-wise , axis=0) or
columns (column-wise, axis=1).
 We can use concat()method when two DataFrames have similar structure.
 Syntax:

panda.concat(objs, axis=0, join=‘outer’, join_axis=None, ignore_index=False)

objs – Multiple DataFrames to be combine / join / concatenate.


axis – {0,1}, default 0. row_wise then axis=0, column_wise then axis=1
join – {‘inner’, ‘outer’}, default is ‘outer’. outer for union and inner for intersection.
join_axis – list of Index objects.
ignore_index – Boolean (True/False), default False. If True, do not use the index values on the
concatenation axis. The resulting axis will be labelled 0, n-1.

(PRADEEP IP CLASSROOM) DataFrame Notes : 31 | P a g e


Here, ignore_index=True will ignore row labels from both the dataframes and the resultant dataframe shall adjust
the index automatically.

(PRADEEP IP CLASSROOM) DataFrame Notes : 32 | P a g e


MERGE OPERATION IN DATAFRAMES

 merge() function is used to join / merge DataFrames.


 Syntax:
panda.merge(objs, on=‘column values’, left_on=‘column values’, right_on= ‘column values’)

Here: on  used in situation when the merge is done on the basis of common column
left_on / right_on  used in situation when merge is done on the basis of different columns in the DataFrame.
The argument “left_on” is to be specified for the left DataFrame and the “right_on” for the right DataFrame name.

(PRADEEP IP CLASSROOM) DataFrame Notes : 33 | P a g e


append() METHOD IN DATAFRAMES

 append() method is used to join / merge DataFrames.


 It appends rows of the second DataFrame at the end of the first DataFrame. Columns not present in the first DataFrame are
added as new columns.
 Syntax:
DataFrame.append (objs)

Parameter used in append() function :


 sort=‘True/False’ ( True – To get the column labels appear in sorted order / False – To get the column labels appear
in unsorted order )
 verify_integrity=‘True/False’ ( True – raise an error if the row labels are duplicate. By default it is ‘False’. )
 ignore_index=‘True/False’ ( True – when we do not want to use row index labels, By default it is ‘False’. )

(PRADEEP IP CLASSROOM) DataFrame Notes : 34 | P a g e


MISSING DATA AND FILLING VALUES

 MISSING VALUES (NaN Not a Number) The values with no computational significance / Undefined values / Unavailable
values / values for which hasn’t entered any value.

 REPLACING MISSING VALUES BY 0 USING fillna() METHOD


 Synatx:
DataFrame_object.fillna(value)

(PRADEEP IP CLASSROOM) DataFrame Notes : 35 | P a g e


 REPLACING CONSTANT VALUE COLUMN-WISE

 Instead of 0, different values / any values can be given column-wise.


 Synatx:

DataFrame_object.fillna({column_name:constant_value})

(PRADEEP IP CLASSROOM) DataFrame Notes : 36 | P a g e


 INTERPOLATE VALUE

 Fills the missing values by copying the values from above adjacent cell (Top cell).
 Synatx:

DataFrame_object.fillna(method = ‘ffill’)

BINARY OPERATIONS ON DataFrame

 Combines two values to produce a new value.


 Pandas provides the methods add(), sub(), mul(), div(), radd(), rsub() for carrying out binary operations on
DataFrame.
 add() – Addition of two DataFrames
 sub() – Subtraction of two DataFrame
 mul() – Multiplication of two DataFrame
 div() – Division of two DataFrame
 radd() – Right side addition. Adds each element in the DataFrame with the corresponding element in the other DataFrame.
 rsub() – Right side subtraction. Subtracts each element in the DataFrame with the corresponding element in the other
DataFrame.

(PRADEEP IP CLASSROOM) DataFrame Notes : 37 | P a g e


(PRADEEP IP CLASSROOM) DataFrame Notes : 38 | P a g e
ATTRIBUTES OF A DATAFRAMES
 Can access certain properties called attributes of a DataFrame by using that property with the DataFrame name.
 Syntax:

DataFrame_object.Attribute name

 COMMON ATTRIBUTES RELATED TO DATAFRAME OBJECT

ATTRIBUTE DESCRIPTION
DataFrame_object.index
index
 Used to display / fetch row labels (index’s name).

DataFrame_object.columns
columns
 Used to display / fetch column labels.
DataFrame_object.axes
axes
 Used to fetch both index(row) and column names.
DataFrame_object.dtypes
dtypes
 Used to display datatypes of each column in the DataFrame.
DataFrame_object.size
size
 Display the size of the DataFrame, which is the product of the number of rows and columns.
DataFrame_object.shape
shape  Display DataFrame size with its shape. i.e. the number of rows and the number of columns of
the DataFrame.
DataFrame_object.ndim
ndim  Used to display the dimensions ( number of axes ) of the given DataFrame, whether it is 1D,
2D or 3D.

(PRADEEP IP CLASSROOM) DataFrame Notes : 39 | P a g e


DataFrame_object.empty
empty  Used to display Boolean output in the form of True or False to find out if there is any empty or
missing value present in the DataFrame.

DataFrame_object.isna()
isna()
 Checks the presence of NaNs (Not a number) in DataFrame.

DataFrame_object.T
T(Transpose)
 Used to transpose the DataFrame i.e. rows becomes columns and columns become rows.

 Example

(PRADEEP IP CLASSROOM) DataFrame Notes : 40 | P a g e


ITERATIONS IN DATAFRAMES

 Accessing and retrieving each record one by one in a dataframe.


 Iteration on DataFrame which can be done using any of the two methods:
 iterrows()
 It represent DataFrame row-wise, record by record.
 Syntax:

DataFrame_object.iterrows()

 iteritems()
 It represent DataFrame columns-wise.
 Syntax:

DataFrame_object.iteritems()

(PRADEEP IP CLASSROOM) DataFrame Notes : 41 | P a g e


DATAFRAME ( IMPORTANT COMMANDS WITH SYNTAX AND DESCRIPTION )
COMMANDS DESCRIPTION
 Used to create DataFrame
 Syntax: DataFrame_object = pd.DataFrame(data, index, columns) /// DataFrame
 Syntax: DataFrame_object = pd.DataFrame() /// empty DataFrame.
 Syntax: DataFrame_object = pd.DataFrame(list, index, columns) /// DataFrame
with List, Nested Lists.
DataFrame()  Syntax: DataFrame_object = pd.DataFrame([Series], index, columns) /// DataFrame
with series / multiple Series.
 Syntax: DataFrame_object = pd.DataFrame(dictionary,index) /// DataFrame with
dictionary.
 Syntax: DataFrame_object = pd.DataFrame(array, index, columns) /// DataFrame
with NumPy array.
}

 Used to sort data present inside the DataFrame.


sort_values()  Syntax: DataFrame_Object.sort_values(by=[Column_Name] , ascending=True/False)
 Used to add new row in a DataFrame.
 Syntax: DataFrame_object.loc[index] = new_value(s)
loc[]  Syntax: DataFrame_object[: ]= any particular value /// Changing all values of
DataFrame to a particular value.
 Used to add new column in a DataFrame.
 Syntax: DataFrame_object[new column label] = new_value(s)
 Syntax: DataFrame_object[column_label] = new_value /// Change the data of
entire column to a particular value in a DataFrame.
 drop() method is used to delete rows and columns from a DataFrame.
drop()  Syntax: DataFrame_object.drop(labels, axis=0/1, inplace=True) /// axis 1 means
column / axis 0 means row
 Delete the entire column and its contains from the DataFrame.
del  Syntax: del DataFrame_object [ column_label ]
 Delete column along with its value and return deleted value.
pop()  Syntax: DataFrame.pop( column_label )
(PRADEEP IP CLASSROOM) DataFrame Notes : 42 | P a g e
 Used to change names of specific column / row as well as can be used to change as many columns / rows
names
 Syntax: DataFrame_object.rename(columns=d, inplace=True)
rename()  Syntax: DataFrame_object.columns=[new_column_name] /// Change the name of
single column
 Syntax: DataFrame_object.rename(index=d, inplace=True)
 Syntax: DataFrame_object.rename(index=d, inplace=True)

 Label based indexing. When a single row label / column label is passed, it returns the row / column as series
 Syntax: DataFrame_object.loc[column_name / row_labels]
loc[]
 Syntax: DataFrame_object.loc[[column_name / row_labels]] /// Multiple rows /
columns.
 Index based indexing. Displays all rows and columns of the DataFrame.
iloc[]
 Syntax: DataFrame_object.iloc[row_indexes, column_indexes]
 Index based indexing. Used to access the single values from DataFrame by their row and column number.
iat[]
 Syntax: DataFrame_object.iat[row_number, column_number]
 Label based indexing. Used to access the single values from DataFrame by their row label and column name.
at[]
 Syntax: DataFrame_object.iat[row_number, column_number]
 Using the functions .loc[] and .iloc[]. The argument passed to these functions is a Boolean value (True
Boolean
[indicated by 1] or False [indicated by 0).
indexing
 Syntax: DataFrame_object.loc/iloc[]
 Used to get the first n rows from the object based on position. By default, it displays the first 5 rows.
head()  Syntax: DataFrame_object.head(n) /// Here, n is the number of rows to be
extracted
 Used to get the first n rows from the object based on position. By default, it displays the last 5 rows.
tail()  Syntax: DataFrame_object.tail(n) /// Here, n is the number of rows to be
extracted

(PRADEEP IP CLASSROOM) DataFrame Notes : 43 | P a g e


 Used to combine or concatenate two or more DataFrames on the basis of rows (row-wise , axis=0) or columns
concat() (column-wise, axis=1).
 panda.concat(objs, axis=0, join=‘outer’, join_axis=None, ignore_index=False)
 Used to join / merge DataFrame.
merge()  panda.merge(objs, on=‘column values’, left_on=‘column values’, right_on=
‘column values’)
 Used to join / merge DataFrame.
append()
 Syntax: DataFrame.append (objs)
 Used to replace missing values (NaN).
 Syntax: DataFrame_object.fillna(value) /// replace NaNs by 0
 Syntax: DataFrame_object.fillna({column_name:constant_value}) /// replacing
fillna()
NaNs by any values.
 Syntax: DataFrame_object.fillna(method = ‘ffill’) /// Fills the missing values
by copying the values from above adjacent cell (Top cell) interpolate values.
 add() /// Addition of two DataFrames
 sub() /// Subtraction of two DataFrame
 mul() /// Multiplication of two DataFrame
Binary  div() /// Division of two DataFrame
operations  radd() /// Right side addition. Adds each element in the DataFrame with the
corresponding element in the other DataFrame.
 rsub() /// Right side subtraction. Subtracts each element in the DataFrame
with the corresponding element in the other DataFrame.
 Used to display / fetch row labels (index’s name).
index
 DataFrame_object.index
 Used to display / fetch column labels.
columns
 DataFrame_object.columns

(PRADEEP IP CLASSROOM) DataFrame Notes : 44 | P a g e


 Used to fetch both index(row) and column names.
axes
 DataFrame_object.axes
 Used to display datatypes of each column in the DataFrame.
dtypes
 DataFrame_object.dtypes
 Display the size of the DataFrame, which is the product of the number of rows and columns.
size
 DataFrame_object.size
 Display DataFrame size with its shape. i.e. the number of rows and the number of columns of the DataFrame.
shape
 DataFrame_object.shape
 Used to display the dimensions ( number of axes ) of the given DataFrame, whether it is 1D, 2D or 3D.
ndim
 DataFrame_object.ndim
 Used to display Boolean output in the form of True or False to find out if there is any empty or missing value
empty present in the DataFrame.
 DataFrame_object.empty
 Checks the presence of NaNs (Not a number) in DataFrame.
isna()
 DataFrame_object.isna()
 Used to transpose the DataFrame i.e. rows becomes columns and columns become rows.
T(Traspose)
 DataFrame_object.T
iterrows()  It represent DataFrame row-wise, record by record.
 DataFrame_object.iterrows()
iteritems()  It represent DataFrame column-wise, record.
 DataFrame_object.iteritems()

(PRADEEP IP CLASSROOM) DataFrame Notes : 45 | P a g e

You might also like