How to have values from a List1 into Columns Names and List 2 Values as Index for an Empty DataFrame

0 votes

List1 = Unique Dates :  eg (10/01/19, 11/01/19, 12/01/19)

List2 = Enroll Numbers : eg (10, 20, 30, 40, 50) 

How can I create a DataFrame with List Values as COlumns and LIst 2 Values as Indexes 

10/01/19 11/01/19 12/01/19
10
20
30
40
50

Regards,

Satya

Jul 10 in Python by satya
• 120 points
47 views

1 answer to this question.

0 votes
Try like this, it will give you same as above

list2 = [10,20,30,40,50]

list1= ["10/01/19","11/01/19","12/01/19"]

df = pd.DataFrame(index = list2,columns = list1,data = " ")

print(df)
answered Jul 10 by Cherukuri
• 32,260 points
list1 also contain " " before the dates to show the topmost left space in the table.

list1= [" ","10/01/19","11/01/19","12/01/19"]

Related Questions In Python

0 votes
1 answer

I'm using Python 2.7 to convert an XML response (from a REST call to Atlassian Fisheye) into an HTML table.

You don't have a template matching tabularQueryResult in your ...READ MORE

answered Oct 4, 2018 in Python by Priyaj
• 57,300 points
56 views
0 votes
1 answer

How do I remove an element from a list by index in Python?

You can use the pop() method to ...READ MORE

answered Jun 21 in Python by Nisa
• 1,090 points
783 views
0 votes
1 answer

How to create a train and test sample from one dataframe using pandas?

Hi, The below written code can help you ...READ MORE

answered Jul 3 in Python by Taj
• 1,040 points
453 views
0 votes
1 answer
0 votes
1 answer

How to write a python script for downloading a video from YouTube and saving it to a directory?

First download pytube using the following code  pip ...READ MORE

answered Sep 4 in Python by Neel
• 3,010 points
477 views
0 votes
1 answer

How can I find out the index of an element from row and column in Python?

You probably want to use np.ravel_multi_index: [code] import numpy ...READ MORE

answered Apr 16, 2018 in Python by charlie_brown
• 7,720 points
109 views
0 votes
1 answer

How can I convert a list of dictionaries from a CSV into a JSON object in Python?

You could try using the AST module. ...READ MORE

answered Apr 17, 2018 in Python by anonymous
854 views
0 votes
1 answer

How to split a string into a list?

You can use the function  text.split() This should be ...READ MORE

answered Jul 30, 2018 in Python by Priyaj
• 57,300 points
74 views