Skip to main content

Mlist

Mlist is a Python list for new advance methods created By Mohit Youtube channel https://www.youtube.com/c/codingwisdom https://www.linkedin.com/in/mohit-990a852a/

Installation

Use the package manager pip to install foobar.

pip install Mlist

Usage

from mlist import Mlist 

# To show the difference between two mlist 
>>> list2 = Mlist([1,2,5,6])
>>> list1 = Mlist([1,2,3,4])
>>>
>>> list1.diffshow(list2)
[5,6]
>>> list1
[1, 2, 3, 4]
>>>
# Based on particular element 
>>> list1 = Mlist([(1,"a"),(2,"b"),(3,"c"),(4,"d")])
>>>
>>> list2 = Mlist([(10,"a"),(20,"b"),(30,"k"),(40,"l")])
>>>
>>> list1.diffshow(list2,1,1)
[(3,"c"),(4,"d")]
>>>
>>> list1 = Mlist([(1,"a"),(2,"b"),(3,"c"),(4,"d")])
>>>
>>> list2 = Mlist([("a",10),("b",20),("k",30),("l",40)])
>>>
# Criteria 2 dimension, 1,0 means Ist value from inner tuple of list1 and 0th value from inner tuple of list2
>>> list1.diffshow(list2,1,0)
[(3,"c"),(4,"d")]

>>> list1 = Mlist([1,2,3,4])
>>> list2 = Mlist([1,2,5,6])
>>>
>>> list1.diff(list2)
>>> list1
[3, 4]

#Get all the indexes
>>> list1 = Mlist([1,2,3,4,5,1,3,1,2,3,4,5])
>>>
>>> list1.indexall(2)
[1, 8]
>>> list1.indexall(5)
[4, 11]
>>>
#Remove all occurrence(s) of given item
>>> list1.removeall(5)
>>> list1
[1, 2, 3, 4, 1, 3, 1, 2, 3, 4]
>>>
# Remove duplicate items
>>> list1.dupr()
>>> list1
[1, 2, 3, 4]
>>>
>>> list1 = Mlist([1,2,3,4])
>>>
>>> list2 = Mlist([1,6,7,2])
>>>
# Substract two lists
>>> list1 - list2
<generator object Mlist.__sub__.<locals>.<genexpr> at 0x00000221FDDE69E0>
>>> [list1 - list2]
[<generator object Mlist.__sub__.<locals>.<genexpr> at 0x00000221FDE49660>]
>>>
>>> Mlist(list1 - list2)
[3, 4]
# lookup like Vlookup
>>> from mlist import Mlist
>>> m1 = Mlist()
>>> m2 = Mlist()
>>> m1.csv_read("G:\\Mlist_experiment\\book1.csv")
[['1', 'a', '400'], ['2', 'b', '500'], ['3', 'c', '600'], ['4', 'd', '700']]
>>>
>>> m2.csv_read("G:\\Mlist_experiment\\book2.csv")
[['Python', '1', '', 'A'], ['java', '2', '', 'B']]
>>>
>>> m1.lookup(m2,0,1)   # 0 means 0 indexed column of m1 and 1 indexed coloum of m2
[['1', 'a', '400'], ['2', 'b', '500']]
>>>
>>> m3=m1.lookup(m2,0,1)
>>> m3
[['1', 'a', '400'], ['2', 'b', '500']]
>>> type(m3)
<class 'mlist.mohit.Mlist'>
>>> m3.csv_write("G:\\Mlist_experiment\\book3.csv")

#Club Two lists 
>>> from mlist import Mlist
>>> m1 = Mlist()
>>> m2 = Mlist()
>>>
>>> m1.csv_read("G:\\Mlist_experiment\\book1.csv") 
[['1', 'a', '400'], ['2', 'b', '500'], ['3', 'c', '600'], ['4', 'd', '700']]
>>> m2.csv_read("G:\\Mlist_experiment\\book2.csv")
[['Python', '1', '', 'A'], ['java', '2', '', 'B']]
>>>
>>> m1.club(m2,0,1) #0 means 0 indexed column of m1 and 1 indexed coloum of m2
>>> m1
[['1', 'a', '400', 'Python', '', 'A'], ['2', 'b', '500', 'java', '', 'B'], ['3', 'c', '600'], ['4', 'd', '700']]
>>> m1.csv_write("G:\\Mlist_experiment\\book4.csv")
>>>

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

APACHE LICENSE, VERSION 2.0

Release files for mlist 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mlist 1.3.0
File Size Uploaded
mlist-1.3.0.tar.gz 3.6 kB Details

Release files / mlist-1.3.0.tar.gz

Download URL mlist-1.3.0.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
fd892b7a4b0c763f5bf8dc80a4a09e1297bb0b25bfdcfdb46fa6cc3510cdd11f
BLAKE2b-256 checksum
How to use checksums
927ba98a96c12e04f7ea9db5ddb3eeb57eeb98471c084a3d0d1b53236b0cc790
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.7

Release history Release notifications | RSS feed

This release

1.3.0 This release

1 release file

1.2.9

1 release file

1.2.5

1 release file

1.2.0

1 release file

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page