Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8150621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:07:19+00:00 2026-06-06T15:07:19+00:00

I am graphing several columns of a large array of data (through numpy.genfromtxt) against

  • 0

I am graphing several columns of a large array of data (through numpy.genfromtxt) against an equally sized time column. Missing data is often referred to as nan, -999, -9999, etc. However I can’t figure out how to remove multiple values from the array. This is what I currently have:

for cur_col in range(start_col, total_col):
    # Generate what is to be graphed by removing nan values
    data_mask = (file_data[:, cur_col] != nan_values)
    y_data = file_data[:, cur_col][data_mask]
    x_data = file_data[:, time_col][data_mask]

After which point I use matplotlib to create the appropriate figures for each column. This works fine if the nan_values is a single integer, but I am looking to use a list.

EDIT: Here is a working example.

import numpy as np

file_data = np.arange(12.0).reshape((4,3))
file_data[1,1] = np.nan
file_data[2,2] = -999
nan_values = -999

for cur_col in range(1,3):
    # Generate what is to be graphed by removing nan values
    data_mask = (file_data[:, cur_col] != nan_values)
    y_data = file_data[:, cur_col][data_mask]
    x_data = file_data[:, 0][data_mask]
    print 'y: ' + str(y_data)
    print 'x: ' + str(x_data)
print file_data

>>> y: [  1.  nan   7.  10.]
    x: [ 0.  3.  6.  9.]
    y: [  2.   5.  11.]
    x: [ 0.  3.  9.]
    [[   0.    1.    2.]
    [   3.   nan    5.]
    [   6.    7. -999.]
    [   9.   10.   11.]]

This will not work if nan_values = [‘nan’, -999] which is what I am looking to accomplish.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T15:07:20+00:00Added an answer on June 6, 2026 at 3:07 pm

    I would suggest using masked arrays like so:

    >>> a = np.arange(12.0).reshape((4,3))
    >>> a[1,1] = np.nan
    >>> a[2,2] = -999
    >>> a
    array([[   0.,    1.,    2.],
           [   3.,   nan,    5.],
           [   6.,    7., -999.],
           [   9.,   10.,   11.]])
    >>> m = np.ma.array(a,mask=(~np.isfinite(a) | (a == -999)))
    >>> m
    masked_array(data =
     [[0.0 1.0 2.0]
     [3.0 -- 5.0]
     [6.0 7.0 --]
     [9.0 10.0 11.0]],
                 mask =
     [[False False False]
     [False  True False]
     [False False  True]
     [False False False]],
           fill_value = 1e+20)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am graphing data from a numpy array using matplotlib imshow. However, some points
Looking at adding some data graphing to a new iPhone app in development (ala
I am graphing some data with ggplot. However, I don't understand the error I'm
My program consists of a large graphing UI control that I need to spend
I have a project that will requiring graphing data (with Python). rrdtool seems to
I am going to be graphing netflow data stored in a MySQL database, and
I have developed a system in R for graphing large datasets obtained from wind
I have a farm of several physical servers each running a large number of
I'm trying to use Raphael.js to do some nice graphing for data after which
I'm working with graphing accelerometer data here, and I'm trying to correct for gravity.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.