Featured Post

8 Ways to Optimize AWS Glue Jobs in a Nutshell

Image
  Improving the performance of AWS Glue jobs involves several strategies that target different aspects of the ETL (Extract, Transform, Load) process. Here are some key practices. 1. Optimize Job Scripts Partitioning : Ensure your data is properly partitioned. Partitioning divides your data into manageable chunks, allowing parallel processing and reducing the amount of data scanned. Filtering : Apply pushdown predicates to filter data early in the ETL process, reducing the amount of data processed downstream. Compression : Use compressed file formats (e.g., Parquet, ORC) for your data sources and sinks. These formats not only reduce storage costs but also improve I/O performance. Optimize Transformations : Minimize the number of transformations and actions in your script. Combine transformations where possible and use DataFrame APIs which are optimized for performance. 2. Use Appropriate Data Formats Parquet and ORC : These columnar formats are efficient for storage and querying, signif

How to Find Max and Min Quickly in Python List

Here's logic to find Max and Min values in a List. Without using built-in Max() and Min () functions you can find Max and Min values in a List. For that matter, you need to write a user-defined function. This post is all about how to write it and run.

Finding Max and Min in List


You can achieve this by writing a user-defined function. Here's useful logic and steps to write it precisely.


IN THIS PAGE

  • Write a Function
  • Execute Function
  • Get the result
  • Write Function

You can write an user-defined function to get MAX and MIN values. In this function, I am using the max(), min() built-in functions. The other variables you can use as you wish. Below is the my actual logic.


Python Function to find Maximum and Minimum Easily


Sample Code

def findmaxmin(data): 
ax = max(data) 
by = min(data) 
return(x,y)
data = (109, 98, 88, 7) 
(maximum, minimum) = findmaxmin (data) 
print("Maximum Marks = ", maximum) 
print("Minimum Marks = ", minimum)


Created a Script Using vim editor

Here as the first step, I have written the maxmin.py file in Ubuntu. The function name is  "findmaxmin ".

define function using input arguments

Result


Below command to enter Python. This command, you can issue in Ubuntu where python3 is installed

$ python3

You have now entered Python3.

>>> import maxmin

You will prompt a message that imported successfully without any syntax errors.

Code in the Python Script


How to import python script and run


Below commands, I have issued.

>>> data = (109, 98, 88, 7)
>>> maxmin.findmaxmin(data)


The result is (109, 7)


References

Comments

Popular posts from this blog

How to Fix datetime Import Error in Python Quickly

How to Check Kafka Available Brokers

SQL Query: 3 Methods for Calculating Cumulative SUM