[ 
https://issues.apache.org/jira/browse/SPARK-38255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17538067#comment-17538067
 ] 

chandan singh commented on SPARK-38255:
---------------------------------------

Hi,

Following is the example in pandas doc 
[https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.loc.html]

Callable that returns a boolean Series
{code:java}
>>> df.loc[lambda df: df['shield'] == 8]  
           max_speed shield 
sidewinder         7      8{code}
 

Below is a toy code example:

 
{code:java}
import pandas as pd
df = pd.DataFrame({"a":[1,2,3,4,5],"b":[4,5,6,6,8]})
def even_index(x):
  return list(map(lambda x:x%2 == 0, df.index.values))
  
df.loc[lambda x:even_index(x)]
{code}
 

 

> Enable a callable in pyspark.pandas.DataFrame.loc
> -------------------------------------------------
>
>                 Key: SPARK-38255
>                 URL: https://issues.apache.org/jira/browse/SPARK-38255
>             Project: Spark
>          Issue Type: Improvement
>          Components: PySpark
>    Affects Versions: 3.2.1
>            Reporter: Kyle Gilde
>            Priority: Minor
>
> Hi,
> I was hoping that you would enable a callable to be used in the 
> pyspark.pandas.DataFrame.loc method.
> I use a lambda function in loc all the time in my pandas code, and I was 
> hoping to be able to use most of my pandas code with your new pandas API.
>  
> Thank you!



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to