Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Aggregate on the entire DataFrame without group

# Aggregate on the entire DataFrame without group

df.agg({"age": "max"}).collect()
# [Row(max(age)=5)]
from pyspark.sql import functions as F
df.agg(F.min(df.age)).collect()
# [Row(min(age)=2)]
Comment

how can i aggregate without group by in pandas

df.groupby(lambda _ : True).agg(new_col_name = ('col_name', 'agg_function'))
Comment

Aggregate on the entire DataFrame without group


def describe(df):
    funcs = dict(Kurt=lambda x: x.kurt(),
                 Skew='skew',
                 Mean='mean',
                 Std='std')
    funcs_for_all = {k: funcs for k in df.columns}
    return df.groupby(lambda _ : True).agg(funcs_for_all).iloc[0].unstack().T

describe(df)

Comment

PREVIOUS NEXT
Code Example
Python :: python removing duplicate item 
Python :: login url 
Python :: python set attribute by string name 
Python :: matplotlib pie move percent 
Python :: How to filter with Regex in Django ORM 
Python :: append a dataframe to an empty dataframe 
Python :: how to make a superuser in django 
Python :: .first() in django 
Python :: WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available. 
Python :: has no attribute python 
Python :: list all files in python 
Python :: if else in python 
Python :: function to remove punctuation in python 
Python :: remove whitespace from data frame 
Python :: python tobytes 
Python :: get particular columns from dataframe 
Python :: pyqt setfocus 
Python :: python doctype 
Python :: dockerfile to run python script 
Python :: list to dic 
Python :: pandas subplots 
Python :: python syntax errors 
Python :: edit path variable using python 
Python :: is python a scripting language 
Python :: How to Connect Google Colab to a Local Jupyter Runtime 
Python :: return function python 
Python :: HTML template with Django email 
Python :: join 3 dataframes by index python 
Python :: how to convert string to float in python 
Python :: django.db.utils.IntegrityError: 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =