I am new to python and have recently learned how to create a series in python using Pandas. I can define a series, for example: x = pd.Series([1, 2, 3, 4, 5])but how to define a series for a range, say from 1 to 100, and not enter all the elements from 1 to 100?
x = pd.Series([1, 2, 3, 4, 5])
As you can see from the docs for pandas.Series , all that is required for your parameter datais an array-like, dict, or scalar value. Therefore, to create a series for a range, you can do the same as creating a list for a range.
data
one_to_hundred = pd.Series(range(1,101))
one_to_hundred=pd.Series(np.arange(1,101,1))
, , numpy arange, , 1 100, 1.
Num = np.arange(1101)
S = pd.Series(NUM)
to see a solution just change what you want. and for details about np.arange see below link https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.arange.html
There is also this:
one_to_hundred = pd.RangeIndex(1, 101).to_series()
I'm still looking for a pandas function that creates a series containing a range (sequence) of numbers directly, but I don't think it exists.