last day (15 days later) » 

9:34 AM
-1
A: Can't figure out the meaning of this code

DeepakWell, I am not sure how to convert from python to Java . But at least i can help you understand what this python code does. I am attaching few snapshot. Hope it helps in someway

 
what about this line of code df.loc[partition].agg(agg_func, squeeze=False)
 
Just check what this variable is "partition" is ?
Here is a nice material to learn almost all useful things on pandas kaggle.com/learn/pandas
 
each partition is a set of strings
 
can you check if those strings are column names of your dataframe. You can check all column names by using df.columns .
It's hard to say by just looking to the codes , but you can check more about it df.loc from here kaggle.com/residentmario/indexing-selecting-assigning
 
No they are values / rows in the column. Thanks
 
9:35 AM
Hey
 
Yes
 
Sure we can talk here....so basically df.loc[partition] will select all the columns available in the partition . That means if the dataframe has 10 columns and partition has 5 columns. df.loc[partition] will select 5 columns from it
 
Alright and .agg(agg_func, squeeze=False) ?
 
after that it will try to aggregate the result based on agg_func. Aggregation you can think as grouping the result like we have in sql.
 
I thought df.loc[partition] will access the specified partition in order to apply agg_func later on it
 
9:44 AM
i depends what your agg_func does...
.agg() will aggregate the result , but how it will aggregate that depends upon what's defined on agg_func
 
as mentioned in the question agg_func is defined as follows :
def agg_func(series):
return [','.join(set(series))]
 
see the documentation.....
in your case DataFrame.agg(func=None, axis=0, *args, **kwargs) is df.loc[partition].agg(agg_func, squeeze=False)
where your func name is agg_func
 
Yes exactly
so basically the line is equivalent to joining distinct partitions from the dataframe in a list of elements (an array of elements)
*distinct elements of the partition
OK, what's also the meaning of this : .agg({_column : 'count'})
 

last day (15 days later) »