0

I'm starting to use pandas with Pyarrow and realized there's no easy way to declare a df directly as with Pyarrow engine, so I ended up in this post. The thing is that I'm having the same isssue as one user comment in the accepted answer.


df = pd.DataFrame({'A' : ['spam', 'eggs', 'spam', 'eggs'] * 2,
                   'B' : ['alpha', 'beta', 'gamma' , 'foo'] * 2,
                   'C' : [np.random.choice(pd.date_range(datetime.datetime(2013,1,1),datetime.datetime(2013,1,3))) for i in range(8)],
                   'D' : np.random.randn(8),
                   'E' : np.random.random_integers(8)}).convert_dtypes(dtype_backend='pyarrow')

This raises NameError: name 'ArrowDtype' is not defined

pandas version == 2.1.0

Using vscode with jupyter integrated terminal.

juanmac
  • 121
  • 1
  • 12

1 Answers1

0

try to modify your code like this:

df = pd.DataFrame({'A' : ['spam', 'eggs', 'spam', 'eggs'] * 2,
                   'B' : ['alpha', 'beta', 'gamma' , 'foo'] * 2,
                   'C' : [np.random.choice(pd.date_range(datetime.datetime(2013,1,1),datetime.datetime(2013,1,3))) for i in range(8)],
                   'D' : np.random.randn(8),
                   'E' : np.random.random_integers(8)}).convert_dtypes(dtype_backend='pyarrow')
Eave_Z
  • 5
  • 4