Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *Important Links
- https://colab.research.google.com/drive/1XVMnEW26FJbMqhzkUNVEAO54UV_jRUbi?usp=sharing#scrollTo=gLb8Q7LGF9dY
- https://colab.research.google.com/drive/1dYskioKSgaTFWgIq7U6hfNKtFgmWRC2C?usp=sharing#scrollTo=0t9FYcLUEWqQ
- https://colab.research.google.com/drive/13x6Rw-IINKaT6enR9iVqzxfkFgWEvPyu?usp=sharing
- https://www.kaggle.com/competitions
- #NumPy
- import numpy as np
- from numpy.random import default_rng
- nums = default_rng().integers(low=-10000, high=10000, size=10000) #generate
- print(nums) #the randomly generated array
- print(nums.shape) #displays the shape of the randomly generated array
- if (nums == 2).any(): #to find the number 2 by iterating through the array
- print((nums == 2)) #displays the boolean values
- print((nums == 2).sum()) #displays the number of times found (sum all True)
- print((nums != 2).sum()) #displays the number of times not found (sum False)
- #Panda
- import pandas as pd
- '''mydataset = {
- 'cars': ["BMW", "Volvo", "Ford","RoyalEnfield"],
- 'passings': [3, 7, 2, 4]
- }'''
- #myvar = pd.DataFrame(mydataset)
- #print(myvar.tail(1))
- #print(myvar['cars'][0])
- #print(myvar.shape)
- #print(myvar.info())
- #print(myvar.describe())
- file_name = "iris.txt"
- df = pd.read_csv(file_name)
- #print(df.head())
- #species = df["species"].unique()
- #print(species)
- #df[df["species"] == 'setosa'] = 1
- #df[df["species"] == 'versicolor'] = 2
- #df[df["species"] == 'virginica'] = 3
- #plt.plot(kind="scatter", x="species", y="petal_width")
- #print(df.plot(kind="hist", x="species", y="petal_width"))
- print(df.shape)
- a = df.dropna()
- print(df.shape)
- print(a.shape)
- b = df.dropna(subset=['petal_length', 'species'])
- print(b.shape)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement