# Pandas single row indexing without casting

Indexing a single row of a Pandas DataFrame containing objects (strings) returns a Series which is of type object.

```
df1 = pd.DataFrame({'a': np.arange(3), 'b': np.arange(0.5,3),'c': list('def')})
df1
a b c
0 0 0.5 d
1 1 1.5 e
2 2 2.5 f
df1.loc[0]
a 0
b 0.5
c d
Name: 0, dtype: object
```

Indexing a single row of a Pandas DataFrame not containing objects (strings) returns a Series which casts its values. Column `a`

is of type `int64`

in the DataFrame. The resulting series contains the value of column `a`

as a `float64`

.

```
df2 = pd.DataFrame({'a': np.arange(3), 'b': np.arange(0.5,3)})
df2
a b
0 0 0.5
1 1 1.5
2 2 2.5
df2.loc[0]
a 0.0
b 0.5
Name: 0, dtype: float64
```

This behavior does not seem consistant, does it?
How can I select a single row of the second DataFrame `df2`

without casting my ints to floats?

W-B
answered question

## Have an answer?

JD

See related question here: stackoverflow.com/questions/47143631