Question: I am trying to do this:

```
.withColumn("System", when($"SysID".split("-").length > 3, $"SysID".split("-").take(3)).otherwise(null))

```

But I get the following error:

error: value split is not a member of org.apache.spark.sql.ColumnName

What can I do to use the split function?

Thank you.

Answer: 
First of all I would advise against using get\_value since it is/will be deprecated. (see: <https://pandas.pydata.org/pandas-docs/version/0.23.4/generated/pandas.DataFrame.get_value.html> )

There are a couple of solutions:

```
df['Salary'].iloc[-1]
df.Salary.iloc[-1]

```

are synonymous. Iloc is the way to retrieve items in a pandas df by their index.

```
df['Salary'].values[-1]

```

creates a list of the Salary column and returns the last items

```
df['Salary'].tail(1)
df.Salary.tail(1)

```

returns the last row of the salary column.

Which of the solutions is best, depends on the context and your personal preference.
In pandas there exists a tail function:

```
>>> df = pd.DataFrame({'animal': ['alligator', 'bee', 'falcon', 'lion',
                   'monkey', 'parrot', 'shark', 'whale', 'zebra']})

>>> df.tail(1)
    animal
8   zebra

```

(See: <https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.tail.html>)

---

Or you could simply do:

```
>>>df[-1:]
    animal
8   zebra

```