Showing posts with the label python series

Featured Post

Python Regex: The 5 Exclusive Examples

 Regular expressions (regex) are powerful tools for pattern matching and text manipulation in Python. Here are five Python regex examples with explanations: 01 Matching a Simple Pattern import re text = "Hello, World!" pattern = r"Hello" result =, text) if result:     print("Pattern found:", Output: Output: Pattern found: Hello This example searches for the pattern "Hello" in the text and prints it when found. 02 Matching Multiple Patterns import re text = "The quick brown fox jumps over the lazy dog." patterns = [r"fox", r"dog"] for pattern in patterns:     if, text):         print(f"Pattern '{pattern}' found.") Output: Pattern 'fox' found. Pattern 'dog' found. It searches for both "fox" and "dog" patterns in the text and prints when they are found. 03 Matching Any Digit   import re text = "The price of the

How to use Pandas Series Method top ideas

Here is an example of how to use a Series constructor in Pandas. A one-dimensional array capable of holding any data type (integers, strings, floating-point numbers, Python objects, etc.) is called a Series object in pandas. Sample DataFrame Single dimension data Below is the single dimension data of Index and Value.  Index  Value  1  10                2  40  3  01  4  99 Having single value for an index is called Single dimensional data. On the other hand, when one index has multiple values, it is called multi-dimensional array.   Below is the example for Multi-dimensional array.  a = (1, (10,20)) mySeries =  pd. Series(data, index=index) Here, pd is a Pandas object. The data and index are two arguments. The  data refers to a Python dictionary of "ndarray"  and index is index of data. Generating DataFrame from single dimension data The below example shows, how to construct single dimension data (Values and Index). >>>mySeries = pd. S eries([10,20,30], index