Hi Guys,
I am importing a dataset from a url using below function:
It works fine and give me a result like:
I want to divide this single column in multiple columns -- eg.. for first row ----first column is for "aris km", 2nd for 21 and third for 1 . This should be based on the characters, like first value "aris km or sovr va is confined within 6 characters -- then 21 is occupying between 8-14 characters and last one is occupying 16 to 18 characters.
If I use split function, I will be able to break it using the space and thus 'aris" and 'km" will also be different columns while it should be same column.
How to break in this way?
I am importing a dataset from a url using below function:
## Import from the url import pandas as pd dftemp=pd.read_csv("http://users.stat.ufl.edu/~winner/data/agedeath.dat") print (dftemp) print (type(dftemp))#####
It works fine and give me a result like:
Output: aris km 21 1
0 aris km 21 2
1 aris km 21 3
2 aris km 21 4
6183 sovr va 100 1439
6184 sovr va 101 1440
[6185 rows x 1 columns] <class 'pandas.core.frame.DataFrame'>
#########
my objective:I want to divide this single column in multiple columns -- eg.. for first row ----first column is for "aris km", 2nd for 21 and third for 1 . This should be based on the characters, like first value "aris km or sovr va is confined within 6 characters -- then 21 is occupying between 8-14 characters and last one is occupying 16 to 18 characters.
If I use split function, I will be able to break it using the space and thus 'aris" and 'km" will also be different columns while it should be same column.
How to break in this way?