Python Forum
Importing file in dataframe and populating missing column name
Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Importing file in dataframe and populating missing column name
#1
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
Reply
#2
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?
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Adding PD DataFrame column bsben 2 246 Mar-08-2024, 10:46 PM
Last Post: deanhystad
  Help copying a column from a csv to another file with some extras g0nz0uk 3 405 Feb-01-2024, 03:12 PM
Last Post: DeaD_EyE
  Python Alteryx QS-Passing pandas dataframe column inside SQL query where condition sanky1990 0 690 Dec-04-2023, 09:48 PM
Last Post: sanky1990
  Difference one column in a dataframe Scott 0 620 Feb-10-2023, 08:41 AM
Last Post: Scott
  splitting a Dataframe Column in two parts nafshar 2 912 Jan-30-2023, 01:19 PM
Last Post: nafshar
  Converting a json file to a dataframe with rows and columns eyavuz21 13 4,174 Jan-29-2023, 03:59 PM
Last Post: eyavuz21
  How to read csv file update matplotlib column chart regularly SamLiu 2 1,016 Jan-21-2023, 11:33 PM
Last Post: SamLiu
  New2Python: Help with Importing/Mapping Image Src to Image Code in File CluelessITguy 0 698 Nov-17-2022, 04:46 PM
Last Post: CluelessITguy
  How to assign a value to pandas dataframe column rows based on a condition klllmmm 0 799 Sep-08-2022, 06:32 AM
Last Post: klllmmm
  renaming the 0 column in a dataframe Led_Zeppelin 5 1,462 Aug-16-2022, 04:07 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020