I'm writing data from dataframe to json file using pandas function .to_json like this:
xx.to_json('file_path',orient='records',lines=True)
The output of this looks like this:
{"speed":null,"state":4.0,"stop_trigger":null,"t":1527237121263,"target_speed":null}
{"speed":null,"state":null,"stop_trigger":null,"t":1527237121264,"target_speed":400.0}
How is it possible to get rid of columns in the output if there are null values?:
{"state":4.0,"t":1527237121263}
{"t":1527237121264,"target_speed":400.0}