Python Forum

Full Version: Importing file in dataframe and populating missing column name
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All,

I am trying to import a survey data on hotel industry . First 2 columns have name and rest of the column doesn't have .I need to populate year_monthNo from column 3.

source AS is

H01: D875
H02: Tourism -unit availabe in thousand
125
126.3
126.7
128
129.1
H01: D875
H02: Tourism -unit sold in thousand
78
80.2
74.3
75.3

Want to convert data into dataframe like this. How can i achieve this.

 ID              Survey Desc                                             Jan-16   Feb-16   Mar-16   Apr-16
H01: D875 H02: Tourism -unit availabe in thousand   125       126.3     126.7     128
H01: D875 H02: Tourism -unit sold in thousand         78         80.2       74.3        75.3 

Thanks
Please post code that you have tried (between the code brackets) as well as any error codes (between the error brackets).

Do you enter the information manually or is it in a database, saved to some type of file (for example, 'csv', excel, or text)?  Are you looking to read and write to the database, or simply read it and format it in the manner that you show in what you expect?