In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "Pandas how to convert the list into a data box", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "Pandas how to convert the list into a data box"!
There are two ways to convert a list into a data box in Python: the first is that two different lists are converted into a data box, and the second is that a list containing different sublists is converted into a data box.
The first: two different lists are converted into data boxes
From pandas.core.frame import DataFramea= [1Jing 2 Jing 3 Jing 4] # Table ab= [5 Jol 6 Jo 7 Jo 8] # list bc= {"a": a, "b": B} # convert the list A Lingo b to a dictionary data=DataFrame (c) # convert the dictionary to a data frame print (data)
The output is
A b0 1 51 2 62 3 73 4 8
Second: convert a list containing different sublists to a data box
From pandas.core.frame import DataFramea= [[1Jing 2je 3jue 4], [5Jing 6je 7je 8]] # contains two different sublists [1je 2je 3je 4] and [5je 6je 7je 8] data=DataFrame (a) # print (data) written according to the standard of conduct at this time.
Output result:
0 1 2 30 1 2 3 41 5 6 7 8data=data.T# transpose to get the desired result data.rename (columns= {0ghuanaxiajin1 inplace=True) # Note that 0 and 1 are not strings print (data) a b051 2 62 3 73 48 Thank you for reading, this is the content of "how Pandas converts a list into a data box", after the study of this article I believe that you have a deeper understanding of how Pandas converts the list into a data box, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.