Question: **this is my dataframe:**

```
c_id  fname  age salary  lname
1      abc   21   21.22   yyy
2      def   41   23.4    zzz

```

i need to display the position of the column name with respect to datatype. so my output should be:

```
**FOR INT:**

col_name  position 
c_id       0
age        2

**for str:**

col_name  position 
fname        1
lname        4

**for float:**

col_name  position 
salary     3

```

Answer: 
IIUC, you can just create a dataframe from the dtypes and reset the index to get the positional index number.

```
col_df = (
pd.DataFrame(df.dtypes, columns=["DataType"])
.rename_axis("Column")
.reset_index()
.rename_axis("Position")
)

          Column DataType
Position                 
0           c_id    int64
1          fname   object
2            age    int64
3         salary  float64
4          lname   object

```

---

```
print(col_df[col_df['DataType'] == 'object'])

         Column DataType
Position                
1         fname   object
4         lname   object

```
You could use .dtypes method on DataFrame

```
df.dtypes
>>> Name      object
    Age        int64
    City      object
    Marks    float64
    dtype: object

df.dtypes['Name']
>>> object

```