title: Remove negative values from a JSON in Python
body: <p>I downloaded some recent earthquake data for visualizing, and I am getting error:</p>
  <blockquote>
  <p>ValueError:
  Invalid element(s) received for the 'size' property of scattergeo.marker
  Invalid elements include: [-0.55, -0.44999999999999996, -0.15, -0.5, -1.5, -0.6, -0.75, -1.9500000000000002, -1.85, -1.5]</p>
  </blockquote>
  <pre><code>The 'size' property is a number and may be specified as:
    - An int or float in the interval [0, inf]
    - A tuple, list, or one-dimensional numpy array of the above
  </code></pre>
  <p>How do I remove the negative elements from the JSON file that I'm using?</p>
  <p>here is my code:</p>
  <pre><code>import json
  from plotly.graph_objs import Layout
  from plotly import offline
  
  # Explore the structure of the data.
  filename = &quot;data/7_day_eq.json&quot;
  with open(filename, encoding=&quot;utf8&quot;) as f:
      all_eq_data = json.load(f)
  
  # Create a file that is more readable.
  readable_file = &quot;data/readable_7_day_eq_data.json&quot;
  with open(readable_file, 'w') as f:
      json.dump(all_eq_data, f, indent=4)
  
  # Take all the information from features key.
  all_eq_dicts = all_eq_data['features']
  
  # Get all the magnitudes.
  mags, lons, lats, hover_texts = [], [], [], []
  for eq_dicts in all_eq_dicts:
      mags.append(eq_dicts['properties']['mag'])
      lons.append(eq_dicts['geometry']['coordinates'][0])
      lats.append(eq_dicts['geometry']['coordinates'][1])
      hover_texts.append(eq_dicts['properties']['title'])
  
  # Map the earthquakes.
  data = [{
      'type': 'scattergeo',
      'lon': lons,
      'lat': lats,
      'text': hover_texts,
      'marker': {
          'size': [5*mag for mag in mags],
          'color': mags,
          'colorscale': 'Viridis',
          'reversescale': True,
          'colorbar': {'title': 'Magnitude'},
      },
  }]
  layout_title = all_eq_data['metadata']['title']
  my_layout = Layout(title=f'Global Earthquakes{layout_title}')
  
  fig = {'data': data, 'layout': my_layout}
  offline.plot(fig, filename='global_earthquakes_7_days.html')
  </code></pre>
  <p>The data for my &quot;7_day_eq.json&quot;  came from <a href="https://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php" rel="nofollow noreferrer">https://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php</a> Past 7 days section and copied all earthquakes into a file.</p>