0

I have have difficult in figuring out how I can turn my specific dataframe from my excel spreadsheet df[50] into a data frame with some specifications. (I do not want the first value into the array). For example df[50] consists of:

print(df[50])

    0  50
    1  29.52
    2  29.97
    3  29.52
    4  29.97
    5  31.5
    6  33.93
    7  36.54
    8  34.02
    9  33.48
    10 32.04
    11 33.03
    12 35.01

What I would like is:

[29.52, 29.97, 29.52, 29.97, 31.5, 33.93, 36.54, 34.02, 33.48, 32.04, 33.03, 35.01]

how would i go about skipping the first value?

Thanks.

2
  • df[50].iloc[1:] should work? Commented Oct 4, 2015 at 5:25
  • when you say array are you meaning a pandas series, numpy array or list? Commented Oct 4, 2015 at 6:23

2 Answers 2

1

I use function tolist() from subset of df selected rows by position iloc[1:]:

print df[50]
#0     29.52
#1     29.97
#2     29.52
#3     29.97
#4     31.50
#5     33.93
#6     36.54
#7     34.02
#8     33.48
#9     32.04
#10    33.03
#11    35.01

List of string:

print [ '%.2f' % elem for elem in df[50].iloc[1:].tolist() ]
#['29.97', '29.52', '29.97', '31.50', '33.93', '36.54', '34.02', '33.48', '32.04', '33.03', '35.01']

List of float:
I has to use function round, because interpretation of float. More info

print [ round(elem, 2) for elem in df[50].iloc[1:].tolist() ]
#[29.97, 29.52, 29.97, 31.5, 33.93, 36.54, 34.02, 33.48, 32.04, 33.03, 35.01]

Series:

print df.iloc[1:,50]
#1     29.97
#2     29.52
#3     29.97
#4     31.50
#5     33.93
#6     36.54
#7     34.02
#8     33.48
#9     32.04
#10    33.03
#11    35.01
#Name: name, dtype: float64

Numpy array:

print np.array(df[50].iloc[1:].tolist())
#[ 29.97  29.52  29.97  31.5   33.93  36.54  34.02  33.48  32.04  33.03  35.01]
Sign up to request clarification or add additional context in comments.

Comments

1

I think this is what your looking for:

df[50].values[1:]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.