- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我无法将此代码转换为 df
我试过了 df = pd.read_json('australian_user_reviews.json')
并有错误: ValueError: Expected object or value
{'user_id': '76561197970982479', 'user_url': 'http://steamcommunity.com/profiles/76561197970982479', 'reviews': [{'funny': '', 'posted': 'Posted November 5, 2011.', 'last_edited': '', 'item_id': '1250', 'helpful': 'No ratings yet', 'recommend': True, 'review': 'Simple yet with great replayability. In my opinion does "zombie" hordes and team work better than left 4 dead plus has a global leveling system. Alot of down to earth "zombie" splattering fun for the whole family. Amazed this sort of FPS is so rare.'}, {'funny': '', 'posted': 'Posted July 15, 2011.', 'last_edited': '', 'item_id': '22200', 'helpful': 'No ratings yet', 'recommend': True, 'review': "It's unique and worth a playthrough."}, {'funny': '', 'posted': 'Posted April 21, 2011.', 'last_edited': '', 'item_id': '43110', 'helpful': 'No ratings yet', 'recommend': True, 'review': 'Great atmosphere. The gunplay can be a bit chunky at times but at the end of the day this game is definitely worth it and I hope they do a sequel...so buy the game so I get a sequel!'}]}
{'user_id': 'js41637', 'user_url': 'http://steamcommunity.com/id/js41637', 'reviews': [{'funny': '', 'posted': 'Posted June 24, 2014.', 'last_edited': '', 'item_id': '251610', 'helpful': '15 of 20 people (75%) found this review helpful', 'recommend': True, 'review': 'I know what you think when you see this title "Barbie Dreamhouse Party" but do not be intimidated by it\'s title, this is easily one of my GOTYs. You don\'t get any of that cliche game mechanics that all the latest games have, this is simply good core gameplay. Yes, you can\'t 360 noscope your friends, but what you can do is show them up with your bad ♥♥♥ dance moves and put them to shame as you show them what true fashion and color combinations are.I know this game says for kids but, this is easily for any age range and any age will have a blast playing this.8/8'}, {'funny': '', 'posted': 'Posted September 8, 2013.', 'last_edited': '', 'item_id': '227300', 'helpful': '0 of 1 people (0%) found this review helpful', 'recommend': True, 'review': "For a simple (it's actually not all that simple but it can be!) truck driving Simulator, it is quite a fun and relaxing game. Playing on simple (or easy?) its just the basic WASD keys for driving but (if you want) the game can be much harder and realistic with having to manually change gears, much harder turning, etc. And reversing in this game is a ♥♥♥♥♥, as I imagine it would be with an actual truck. Luckily, you don't have to reverse park it but you get extra points if you do cause it is bloody hard. But this is suprisingly a nice truck driving game and I had a bit of fun with it."}, {'funny': '', 'posted': 'Posted November 29, 2013.', 'last_edited': '', 'item_id': '239030', 'helpful': '1 of 4 people (25%) found this review helpful', 'recommend': True, 'review': 'Very fun little game to play when your bored or as a time passer. Very gud. Do Recommend. pls buy'}]}
{'user_id': 'evcentric', 'user_url': 'http://steamcommunity.com/id/evcentric', 'reviews': [{'funny': '', 'posted': 'Posted February 3.', 'last_edited': '', 'item_id': '248820', 'helpful': 'No ratings yet', 'recommend': True, 'review': "A suitably punishing roguelike platformer. Winning feels good. Progressive unlocks mean a good slog ending in failure doesn't feel like a waste."}, {'funny': '', 'posted': 'Posted December 4, 2015.', 'last_edited': 'Last edited December 5, 2015.', 'item_id': '370360', 'helpful': 'No ratings yet', 'recommend': True, 'review': '"Run for fun? What the hell kind of fun is that?"'}, {'funny': '', 'posted': 'Posted November 3, 2014.', 'last_edited': '', 'item_id': '237930', 'helpful': 'No ratings yet', 'recommend': True, 'review': 'Elegant integration of gameplay, story, world development and aesthetic.'}, {'funny': '', 'posted': 'Posted October 15, 2014.', 'last_edited': '', 'item_id': '263360', 'helpful': 'No ratings yet', 'recommend': True, 'review': 'Random drops and random quests, with stat points. Animation style reminiscent of the era before the Voodoo card.'}, {'funny': '', 'posted': 'Posted October 15, 2014.', 'last_edited': '', 'item_id': '107200', 'helpful': 'No ratings yet', 'recommend': True, 'review': 'Fun balance of tactics and strategy. Potential for very rewarding battles on smaller maps. Can become a bit of a grind on larger maps (>200 stars).'}, {'funny': '', 'posted': 'Posted October 15, 2014.', 'last_edited': '', 'item_id': '224500', 'helpful': 'No ratings yet', 'recommend': True, 'review': 'Fun world builder, with plenty of option of how you want challenge served to you. Gnome pathing sometimes frustrating if you expand very very quickly.'}]}
{'user_id': 'doctr', 'user_url': 'http://steamcommunity.com/id/doctr', 'reviews': [{'funny': '', 'posted': 'Posted October 14, 2013.', 'last_edited': '', 'item_id': '250320', 'helpful': '2 of 2 people (100%) found this review helpful', 'recommend': True, 'review': 'This game... is so fun. The fight sequences have been improved from walking dead. It also includes more of a Sam and Max puzzle solving (some of it in the first episode) and walking dead. The game also gets even more better if you have read the Fables comic books, which are without a doubt, very good. The music is also superb and fit the scenarios very well.'}, {'funny': '', 'posted': 'Posted July 28, 2012.', 'last_edited': '', 'item_id': '20920', 'helpful': '1 of 1 people (100%) found this review helpful', 'recommend': True, 'review': "Really Really Really Great Game, very good story, im in chapter 1 atm and i think its great. You get a really early link with characters. No need to play the first game, its nicely wrapped up for you in a five minute video. FYI beware of the sex scenes :P, nudity does happen in the game and it shows you actually having sex, so try not to play with your parents around if your near a point in the story. Also you will need a good rig/comp to play on high. Don't even try running the game on Ultra unless you have mulitiple GPU's (Graphics card) and ram and a good processor. All in all good game :D"}, {'funny': '', 'posted': 'Posted June 2, 2012.', 'last_edited': '', 'item_id': '204100', 'helpful': '1 of 1 people (100%) found this review helpful', 'recommend': True, 'review': 'Just buy it already. Great Story, Great Multiplayer and good fan service. Just awesome game. Just using shootdodge and bullet time makes you feel like a badass. Also, its better if you get the max payne story recapped or replay the first two but its not necessary.'}, {'funny': '', 'posted': 'Posted June 29, 2014.', 'last_edited': '', 'item_id': '224600', 'helpful': '1 of 2 people (50%) found this review helpful', 'recommend': True, 'review': 'It was a great game from what I played, right now I need to find the actual download.'}, {'funny': '', 'posted': 'Posted November 22, 2012.', 'last_edited': '', 'item_id': '207610', 'helpful': 'No ratings yet', 'recommend': True, 'review': "The ending to this game is.... ♥♥♥♥♥♥♥.... Just buy it, you'll be invested, im automatically preordering season two of the walking dead game."}, {'funny': '', 'posted': 'Posted February 23, 2012.', 'last_edited': '', 'item_id': '108710', 'helpful': 'No ratings yet', 'recommend': True, 'review': 'Alan wake is a really good game, the light effects are pretty awesome and this game is so good, it paid back remedy their promotion and conversion fees in the first two days on steam. Its awesome :D. Remedy can still make video games, even if its not Max Payne. It is also very character driven.'}]}
{'user_id': 'maplemage', 'user_url': 'http://steamcommunity.com/id/maplemage', 'reviews': [{'funny': '3 people found this review funny', 'posted': 'Posted April 15, 2014.', 'last_edited': '', 'item_id': '211420', 'helpful': '35 of 43 people (81%) found this review helpful', 'recommend': True, 'review': 'Git gud'}, {'funny': '1 person found this review funny', 'posted': 'Posted December 23, 2013.', 'last_edited': '', 'item_id': '211820', 'helpful': '12 of 16 people (75%) found this review helpful', 'recommend': True, 'review': "It's like Terraria, you play for 9 hours straight, get endgame armour then stop playing until the next update."}, {'funny': '2 people found this review funny', 'posted': 'Posted March 14, 2014.', 'last_edited': '', 'item_id': '730', 'helpful': '5 of 5 people (100%) found this review helpful', 'recommend': True, 'review': 'Hold shift to win, Hold CTRL to lose.'}, {'funny': '', 'posted': 'Posted July 11, 2013.', 'last_edited': '', 'item_id': '204300', 'helpful': 'No ratings yet', 'recommend': True, 'review': "OH YES, THIS GAME IS THE BEST, THEY ADD STUFF LIKE NEW CHARACTERS, AND LIKE A NEW MAP ONCE A YEAR, IT'S SO AWESOME, OH YES, IT'S SO AWESOMENAUTS, YES, YES, I'M GOOD AT THIS, YES, YES, GOOD, I'M GOOD, YES, GOOD, YOU ARE BAD, IM GOOD, YES, TOO GOOD, YES, IM NOT BAD, YES, GOOD."}]}
最佳答案
这是你的json的问题
使用这个json
{
"bundle_final_price": "$29.66",
"bundle_url": "http://store.steampowered.com/bundle/1482/?utm_source=SteamDB...",
"bundle_price": "$32.96",
"bundle_name": "Two Tribes Complete Pack!",
"bundle_id": "1482",
"items": [{"genre": "Casual, Indie", "item_id": "38700", "discounted_price": "$4.99", "item_url": "http://store.steampowered.com/app/38700", "item_name": "Toki Tori"}, {"genre": "Adventure, Casual, Indie", "item_id": "201420", "discounted_price": "$14.99", "item_url": "http://store.steampowered.com/app/201420", "item_name": "Toki Tori 2+"}, {"genre": "Strategy, Indie, Casual", "item_id": "38720", "discounted_price": "$4.99", "item_url": "http://store.steampowered.com/app/38720", "item_name": "RUSH"}, {"genre": "Action, Indie", "item_id": "38740", "discounted_price": "$7.99", "item_url": "http://store.steampowered.com/app/38740", "item_name": "EDGE"}],
"bundle_discount": "10%"
}
所有值都应该用双引号引起来,否则会给 pandas.read_json
带来 ValueError
错误。您可以做的是将单引号替换为双引号。
df2 = pd.read_json('s.json')
bundle_final_price ... bundle_discount
0 $29.66 ... 10%
1 $29.66 ... 10%
2 $29.66 ... 10%
3 $29.66 ... 10%
关于python - 将 JSON 转换为 pd.DataFrame,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55338899/
假设我有 3 个 DataFrame。其中一个 DataFrame 的列名不在其他两个中。 using DataFrames df1 = DataFrame([['a', 'b', 'c'], [1,
假设我有 3 个 DataFrame。其中一个 DataFrame 的列名不在其他两个中。 using DataFrames df1 = DataFrame([['a', 'b', 'c'], [1,
我有一个 largeDataFrame(多列和数十亿行)和一个 smallDataFrame(单列和 10,000 行)。 只要 largeDataFrame 中的 some_identifier 列
我有一个函数,可以在其中规范化 DataFrame 的前 N 列。我想返回规范化的 DataFrame,但不要管原来的。然而,该函数似乎也会对传递的 DataFrame 进行变异! using D
我想在 Scala 中使用指定架构在 DataFrame 上创建。我尝试过使用 JSON 读取(我的意思是读取空文件),但我认为这不是最佳实践。 最佳答案 假设您想要一个具有以下架构的数据框: roo
我正在尝试从数据框中删除一些列,并且不希望返回修改后的数据框并将其重新分配给旧数据框。相反,我希望该函数只修改数据框。这是我尝试过的,但它似乎并没有做我所除外的事情。我的印象是参数是作为引用传递的,而
我有一个包含大约 60000 个数据的庞大数据集。我会首先使用一些标准对整个数据集进行分组,接下来我要做的是将整个数据集分成标准内的许多小数据集,并自动对每个小数据集运行一个函数以获取参数对于每个小数
我遇到了以下问题,并有一个想法来解决它,但没有成功:我有一个月内每个交易日的 DAX 看涨期权和看跌期权数据。经过转换和一些计算后,我有以下 DataFrame: DaxOpt 。现在的目标是消除没有
我正在尝试做一些我认为应该是单行的事情,但我正在努力把它做好。 我有一个大数据框,我们称之为lg,还有一个小数据框,我们称之为sm。每个数据帧都有一个 start 和一个 end 列,以及多个其他列所
我有一个像这样的系列数据帧的数据帧: state1 state2 state3 ... sym1 sym
我有一个大约有 9k 行和 57 列的数据框,这是“df”。 我需要一个新的数据框:'df_final'- 对于“df”的每一行,我必须将每一行复制“x”次,并将每一行中的日期逐一增加,也就是“x”次
假设有一个 csv 文件如下: # data.csv 0,1,2,3,4 a,3.0,3.0,3.0,3.0,3.0 b,3.0,3.0,3.0,3.0,3.0 c,3.0,3.0,3.0,3.0,3
我只想知道是否有人对以下问题有更优雅的解决方案: 我有两个 Pandas DataFrame: import pandas as pd df1 = pd.DataFrame([[1, 2, 3], [
我有一个 pyspark 数据框,我需要将其转换为 python 字典。 下面的代码是可重现的: from pyspark.sql import Row rdd = sc.parallelize([R
我有一个 DataFrame,我想在 @chain 的帮助下对其进行处理。如何存储中间结果? using DataFrames, Chain df = DataFrame(a = [1,1,2,2,2
我有一个包含 3 列的 DataFrame,名为 :x :y 和 :z,它们是 Float64 类型。 :x 和 "y 在 (0,1) 上是 iid uniform 并且 z 是 x 和 y 的总和。
这个问题在这里已经有了答案: pyspark dataframe filter or include based on list (3 个答案) 关闭 2 年前。 只是想知道是否有任何有效的方法来过
我刚找到这个包FreqTables ,它允许人们轻松地从 DataFrames 构建频率表(我正在使用 DataFrames.jl)。 以下代码行返回一个频率表: df = CSV.read("exa
是否有一种快速的方法可以为 sort 指定自定义订单?/sort!在 Julia DataFrames 上? julia> using DataFrames julia> srand(1); juli
在 Python Pandas 和 R 中,可以轻松去除重复的列 - 只需加载数据、分配列名,然后选择那些不重复的列。 使用 Julia Dataframes 处理此类数据的最佳实践是什么?此处不允许
我是一名优秀的程序员,十分优秀!