#NEWLINE# def test_append_spark_df_to_json_lines( ctx ) : #NEWLINE# #INDENT# out = os . linesep . join ( map ( json . dumps , df . to_dict ( 'records' ) ) ) #NEWLINE# sdf = ctx . table ( 't' ) #NEWLINE# expected = pd . concat ( [ df , df ] ) . sort ( 'amount' ) . reset_index ( drop = True ) . sort_index ( axis = 1 ) #NEWLINE# with tmpfile ( '.json' ) as fn : #NEWLINE# #INDENT# with open ( fn , mode = 'w' ) as f : #NEWLINE# #INDENT# f . write ( ( out + os . linesep ) ) #NEWLINE# #UNINDENT# uri = ( 'jsonlines://%s' % fn ) #NEWLINE# odo ( sdf , uri ) #NEWLINE# result = odo ( uri , pd . DataFrame ) . sort ( 'amount' ) . reset_index ( drop = True ) . sort_index ( axis = 1 ) #NEWLINE# tm . assert_frame_equal ( result , expected )