Python Forum
Importing file in dataframe and populating missing column name - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Importing file in dataframe and populating missing column name (/thread-2203.html)



Importing file in dataframe and populating missing column name - vvv - Feb-26-2017

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


RE: Importing file in dataframe and populating missing column name - sparkz_alot - Feb-26-2017

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?