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, 2019 in Python by satya
• 120 points
278 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, 2019 by Cherukuri
• 32,910 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

How to remove an element from a list by index?

Use del and specify the index of the element ...READ MORE

answered Dec 18, 2020 in Python by Gitika
• 65,870 points
35 views
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
• 58,100 points
233 views
0 votes
4 answers

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

1886 Use del and specify the index of the element ...READ MORE

answered Dec 11, 2020 in Python by Gitika
• 65,870 points
54,909 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, 2019 in Python by Taj
• 1,080 points
4,198 views
0 votes
0 answers
0 votes
2 answers
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, 2019 in Python by Neel
• 3,020 points
1,197 views
0 votes
1 answer

How to convert a dataframe into list?

Hi@akhtar, You can convert your dataframe into list. ...READ MORE

answered Apr 24, 2020 in Python by MD
• 95,060 points
104 views
0 votes
1 answer

How to Filter for empty or NULL names in a queryset?

Hello @kartik, You could do this: Name.objects.exclude(alias__isnull=True) If you need ...READ MORE

answered Aug 6, 2020 in Python by Niroj
• 82,560 points
420 views