bikuser
bikuser

Reputation: 2093

how to delete whitespace from nd array python

I have yearly data sets with some missing data. I used this code to read but unable to omit white space present at the end of february. can anyone help to solve this problem?

df1 = pd.read_fwf('DQ404.7_77.txt',widths=ws,header=9, nrows=31, keep_default_na = False)
df1 = df1.drop('Day', 1)
df2 = np.array(df1).T 

what I want is to arrange all the data in one column with respect to date. My data is uploaded in this link you can download https://drive.google.com/open?id=0B2rkXkOkG7ExbEVwZUpHR29LNFE

what i wanted is to get time series data from this file and it should be like

Feb,25  13
Feb,26  13
Feb,27  13
Feb,28  13
March, 1    10
March, 2    10
March, 3    10

Not with empty strings in between february and March

Upvotes: 1

Views: 2021

Answers (1)

EdChum
EdChum

Reputation: 394071

So after a lot of comments it looks like df[df != ''] works for you

Upvotes: 2

Related Questions