Every line of 'convert list of json to dataframe python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
25 def python_to_json(python_data): 26 '''Convert python data (tuple, list, dict, etc) into json string''' 27 json_str = json.dumps(python_data, indent=4) 28 return json_str
20 def json_dir_to_dataframe(json_dir): 21 files = sorted(os.listdir(json_dir), key=lambda f:int(f.split('.')[0])) 22 def load(name): 23 with open(os.path.join(json_dir, name)) as f: 24 d = json.load(f) 25 del d['steps'], d['log_file'] 26 d.pop('git_revision', None) 27 d.pop('prev_git_revision', None) 28 return d 29 return pd.io.json.json_normalize([load(f) for f in files])
23 def df_to_json(df): 24 """Convert DataFrame to a list of dicts, then dump to JSON.""" 25 jsondict = df_to_jsondict(df) 26 return dump_mongo_json(jsondict)
76 def test_json(): 77 df = rc.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6], 'c': [7, 8, 9]}, index=[4, 5, 6], columns=['b', 'a', 'c']) 78 79 string = df.to_json() 80 actual = rc.DataFrame.from_json(string) 81 assert_frame_equal(df, actual) 82 83 # empty DataFrame 84 df = rc.DataFrame({'a': [], 'b': [], 'c': []}) 85 string = df.to_json() 86 actual = rc.DataFrame.from_json(string) 87 assert_frame_equal(df, actual) 88 89 df = rc.DataFrame() 90 string = df.to_json() 91 actual = rc.DataFrame.from_json(string) 92 assert_frame_equal(df, actual)
21 def h2oToList(h2o_frame): 22 h2o_frame = h2o_frame.get_frame_data() 23 return h2o_frame.split("\n")[1:-1]
63 def export_gene_list_to_json(dataframe, file_name): 64 gene_list_file_path = os.path.join(RESOURCES_PATH, file_name) 65 66 return dataframe.to_json( 67 path_or_buf=gene_list_file_path, 68 orient='values' 69 )
706 def json_to_data(s): 707 """ 708 """ 709 710 return json.loads(s, object_hook=restore)
84 def _get_dataframe_as_json(self, pandas_df): 85 return pandas_df.head(self.max_rows).to_json(orient=u'records')
605 def _parse_numpy(self): 606 607 json = self.json 608 orient = self.orient 609 610 if orient == "columns": 611 args = loads(json, dtype=None, numpy=True, labelled=True, 612 precise_float=self.precise_float) 613 if args: 614 args = (args[0].T, args[2], args[1]) 615 self.obj = DataFrame(*args) 616 elif orient == "split": 617 decoded = loads(json, dtype=None, numpy=True, 618 precise_float=self.precise_float) 619 decoded = dict((str(k), v) for k, v in compat.iteritems(decoded)) 620 self.check_keys_split(decoded) 621 self.obj = DataFrame(**decoded) 622 elif orient == "values": 623 self.obj = DataFrame(loads(json, dtype=None, numpy=True, 624 precise_float=self.precise_float)) 625 else: 626 self.obj = DataFrame(*loads(json, dtype=None, numpy=True, 627 labelled=True, 628 precise_float=self.precise_float))
22 def maybe_to_df(object_): 23 """ 24 Convert pd.Series and robjects.DataFrame to pd.DataFrame. 25 """ 26 if isinstance(object_, pd.Series): 27 object_ = object_.to_frame() 28 object_ = r_to_py(object_) 29 return object_