<jupyter_start><jupyter_text>PANDAS  Series<jupyter_code>import pandas as pd
import numpy as np
# This is just using for further use
labels = ['a','b','c'] # Python list
my_data = [10,20,30] # Python list
arr = np.array(my_data) # A numpy array
d = {'a':10, 'b':20, "c":30}  # Python dictionary
labels
my_data
arr
d
pd.Series(data = my_data) # Making series in pandas,note they also make serial no. for you
pd.Series(data = d) # Series in dictionaries IMPORTANT
pd.Series(data = arr) # Using a numpy array
pd.Series(data = labels)<jupyter_output><empty_output><jupyter_text>Series with labeled index<jupyter_code>pd.Series(data = my_data, index = labels) # Using 'labels' as index
pd.Series(my_data, labels) # Meathod 2 of doing the same
pd.Series(arr, labels) # Using numpy array in the same
pd.Series(data=['Himanshu', 'Ishika', 'Vineeta', 'Jagdish']) # Any type data is allowed in pandas
pd.Series(data = [sum, print, len]) # Python built in funtions too...<jupyter_output><empty_output><jupyter_text>Grabbing information from a series<jupyter_code>ser1 = pd.Series(['USA', 'India', 'Japan', 'Germany'], [1,2,3,4])
ser1 # Making a SERIES for further use
ser2 = pd.Series(['USA', 'India', 'Italy', 'Germany'], [1,2,5,4])
ser2 # Making another SERIES for the use
print(ser1[1]) # Grabbing information from series 1
print(ser1[2])
print(ser1[3])
print(ser1[4])
print(ser2[1]) # Grabbing information from series 2
print(ser2[2])
print(ser2[5])
print(ser2[4])
ser3 = pd.Series(data = labels, index = [1,2,3]) # NOthing but making of a new ser
ser3
print(ser3[1]) # Components of series 3
print(ser3[2])
print(ser3[3])<jupyter_output>a
b
c<jupyter_text>OPERATIONS with series<jupyter_code>print(f'series_1 = \n{ser1}\n') # Printing just for further use
print(f'series_2 = \n{ser2}\n')
ser1 + ser2 # This will add up the data and NAN in case no common component found in both of the series
ser4 = pd.Series(data = [1,2,3,4,5,6,7,8,9,10], index = ['India','USA','Japan','Russia','Brazil','China','Australia','New Zealand','USSR','Nigeria'])
ser4
ser5 = pd.Series(data = [2,3,5,4,3,2,4,5,6,9], index = ['India','USA','Japan','Russia','Brazil','Hong Kong','Australia','New Zealand','Kenya','Nigeria'])
ser5
ser4 + ser5 # This will add up the data of both the series
ser4 - ser5 # Subtraction of the series DATA
ser4 / ser5 # DIVIDE
ser4 % ser5 # remainder<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1576955424726661, 'fraction_numerical': 0.03952901597981497, 'mean_word_length': 6.1441441441441444, 'pattern_counts': {'":': 1, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '224428', 'license': 'MIT', 'n_tokens_mistral': 912, 'n_tokens_neox': 870, 'n_words': 252, 'path': 'Pandas/Series in PANDAS.ipynb', 'repo_name': 'HimanshuPoptani/Machine-Learing', 'size': '2378'}