Eric
Eric

Reputation: 153

python DataFrame data export to stata using to_stata() raise ValueError

I use to_stata() to exporting my DataFrame

AppliedTariff.to_stata('Applied%s.dta' % name, write_index = False)

raise ValueError('Writing general object arrays is not supported')

I do not know how to continue.

Upvotes: 5

Views: 3436

Answers (1)

Martien Lubberink
Martien Lubberink

Reputation: 2735

See the answer via this link.

Find out which columns are of the object type:

list(df.select_dtypes(include=['object']).columns)

Convert them to something else: df['col'] = df['col'].astype(str)

Upvotes: 3

Related Questions