Reputation: 6668
I have been sent a file. I have read it in as a dataframe which contains only one column and over a 1,000,000 rows. Each row is a mixture of numbers and text.
I tried the following line below.
data = data.str.split('/t',expand=True)
However I get the error below,
AttributeError: 'DataFrame' object has no attribute 'str'
I thought maybe it was because its of type object and not string. So tried the line below however that seems to have no effect.
data.astype('str')
How can I split this column?
Upvotes: 1
Views: 71
Reputation: 862651
I think there is one column DataFrame
, so for one column is possible select first column by position with DataFrame.iloc
:
data = data.iloc[:, 0].str.split('/t',expand=True)
Or if psosible select first column by name:
data = data['col'].str.split('/t',expand=True)
Upvotes: 1