Use the td_range() function to create a DataFrame with a specified range of numbers.
- The range is inclusive of the start and exclusive of the end.
- If only start is provided, then end is set to start and start is set to 0.
Required Parameter
- start
- Specifies the starting number of the range.
Optional Parameters
- end
- Specifies the end number of the range (exclusive).
Default value: None
- step
- Specifies the step size of the range.
Default value: 1
Example 1: Create a DataFrame with a range of numbers from 0 to 5
from teradataml.dataframe.functions import td_range
df = td_range(5)
df.sort('id')
id 0 0 1 1 2 2 3 3 4 4
Example 2: Create a DataFrame with a range of numbers from 5 to 1 with default step size of -2
from teradataml.dataframe.functions import td_range td_range(5, 1, -2)
id 0 3 1 5
Example 3: Create a DataFrame with a range of numbers from 1 to 5 with default step size of 1
from teradataml.dataframe.functions import td_range td_range(1, 5)
id 0 3 1 4 2 2 3 1