DataFrame in Pandas in Python by R4R Team

DataFrames:
-It is a two dimensional data structure defined in pandas which consists of rows and columns.

Syntax-

pandas.DataFrame(data)

Here data can be :
1. one or more dictionary.
2. one or more series
3. 2D numpy Ndarray

List in DataFrames-


program-

import pandas

list=['a','b','c','d']
ans=pandas.DataFrame(list)
print(ans)
print("Then-")
print(ans[0])
print(ans[0][0])


output-

0
0 a
1 b
2 c
3 d
Then-
0a
1b
2c
3d
Name: 0, dtype: object

-In this program, we create a two dimensional array by list with all default index value in both dimension.
-Then ans[0] will give array at 0th index
-And ans[0][0] will give 1st element that present at 0th index of 0th index.




Leave a Comment: