Skip to content

error in row indexing using loc #6483

Closed
@jkokorian

Description

@jkokorian

I am trying to get the value of a dataframe column that contains numpy arrays. The index is a timestamp.The dataframe column has the dtype 'O', which is essential for reproducing the bug.

import pandas as pd
import numpy as np
from pandas import Timestamp

timestamps = pd.Series(data=[Timestamp('2014-07-01 11:19:07.888000', tz=None),Timestamp('2014-07-01 11:19:08.094000', tz=None),Timestamp('2014-07-01 11:19:08.299000', tz=None)],name='timestamp')
data = pd.Series(dtype='O',data=[np.array([1,2,3]),np.array([4,5,6]),np.array([7,8,9])],index=timestamps)
df = pd.DataFrame(data=data,columns=['a'])

i = df.index[0]

#this works as intended, produces a single row of the dataframe
df.loc[i]

#this gives an error (which it shouldn't do). It should have produced the array [1,2,3]
df.a.loc[i0]

#this works as a workaround, but it's a bit ugly
df.a.get_value(i)

I really hopes that this can get fixed, thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions