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
1,045 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
• 33,030 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,770 points
771 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,020 points
1,446 views
+1 vote
4 answers

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

Delete the List and its element: We have ...READ MORE

answered Jun 7, 2020 in Python by sahil
• 500 points
280,722 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 4, 2019 in Python by Taj
• 1,080 points
5,744 views
0 votes
0 answers
–1 vote
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
2,681 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 25, 2020 in Python by MD
• 95,460 points
710 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,840 points
5,090 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP