In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces how to analyze the orient attributes read by json. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.
The last line of the csv file is a few cells in json format, which I was stuck on this afternoon and couldn't parse the desired format all the time.
For example, a cell json string is formatted as:
{"status": 0, "msg":, result: [{"S1": 1, "S2": "ming"}, {"S1": 20, "S2": "xxx"}]}, the simplified value.
With pandas, I want to convert the above json string to a dataframe object, and using: pd.read_json (jsonStr, orient= "index") will report an exception of similar inconsistent length.
After that, the original string is processed, leaving only: result: [{"S1": 1, "S2": "ming"}, {"S1": 20, "S2": "xxx"}]
And then read_json, where there is a key attribute orient, which determines the parsing format of the read-in json
'split': dict like {index-> [index], columns-> [columns], data-> [values]}
'records': list like [{column-> value},..., {column-> value}]
'index': dict like {index-> {column-> value}}
'columns': dict like {column-> {index-> value}}
'values': just the values array
As can be seen above, the matching orient is records, and the dataframe in the following format can only be obtained after reading:
S1 s2
0 1 ming
1 20 xxx
The main problem at that time was that the orient attribute value (records) was not set properly. Just for this short note, stop writing and have a rest.
On how to parse the json read into the orient properties to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
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.