Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedJoin us at the 2025 Microsoft Fabric Community Conference. March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for $400 discount. Register now
It would be really useful if we had a Pyspark forum
Im SQL through and through and learning Pyspark is a NIGHTMARE
I have the following code that finds all the contestants with more that one record in a list that should be unique
Solved! Go to Solution.
Hi @DebbieE ,
Thanks for using Fabric Community.
As I understand -
Spark SQL Code:
df = spark.sql("SELECT Min(CustomerID), CompanyName, Count(*) FROM gopi_lake_house.customer_table1 group by CompanyName having count(*)>1")
display(df)
Pyspark Code:
Can you please try below code -
from pyspark.sql.functions import *
result = dfcont.groupBy('CompanyName')\
.agg(min('CustomerID').alias('minCustomerID'), count('CustomerID').alias('TotalRecords'))\
.filter(col('TotalRecords') > 1)\
.show(1000)
Hope this is helpful. Please let me know incase of further queries.
Yey. It worked. thank you so much. the excercise is to try to do everything I usually do with pyspark so having these extra examples are gold too.
Hi @DebbieE ,
Glad to know that your query got resolved. Please continue using Fabric Community on your further queries.
Hi @DebbieE ,
Thanks for using Fabric Community.
As I understand -
Spark SQL Code:
df = spark.sql("SELECT Min(CustomerID), CompanyName, Count(*) FROM gopi_lake_house.customer_table1 group by CompanyName having count(*)>1")
display(df)
Pyspark Code:
Can you please try below code -
from pyspark.sql.functions import *
result = dfcont.groupBy('CompanyName')\
.agg(min('CustomerID').alias('minCustomerID'), count('CustomerID').alias('TotalRecords'))\
.filter(col('TotalRecords') > 1)\
.show(1000)
Hope this is helpful. Please let me know incase of further queries.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Fabric update to learn about new features.
User | Count |
---|---|
29 | |
3 | |
2 | |
2 | |
2 |
User | Count |
---|---|
14 | |
8 | |
7 | |
5 | |
4 |