python 2.7 - Pandas dataframe applying NA to part of the data -


let me preface new @ using pandas i'm sorry if question basic or answered before, looked online , couldn't find needed.

i have dataframe consists of baseball teams schedule. of games have been played , result results game inputed in dataframe. however, games yet happen, there time played (eg 1:35 pm).

so, convert of values of games yet happen na's.

thank you

as requested here results dataframe arizona diamondbacks contains

print mlb['ari'] 0     0 1     0 2     0 3     1 4     0 5     0 6     0 7     0 8     1 9     0 10    1 ... 151    3:40 pm 152    8:40 pm 153    8:10 pm 154    4:10 pm 155    4:10 pm 156    8:10 pm 157    8:10 pm 158    1:10 pm 159    9:40 pm 160    8:10 pm 161    4:10 pm name: ari, length: 162, dtype: object 

couldn't figure out direct solution, iterative

for in xrange(len(mlb)):     if 'pm' in mlb.['ari'].iat[i] or 'am' in mlb.['ari'].iat[i]:         mlb.['ari'].iat[i] = np.nan 

this should work if actual values (1s , 0s) strings. if numbers, try:

for in xrange(len(mlb)):     if type(mlb.['ari'].iat[i]) != type(1):         mlb.['ari'].iat[i] = np.nan 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -