Question

Problem 2 using Python NumPy and Pandas libraries NOTES: Import NumPy as np and Pandas as...

Problem 2 using Python NumPy and Pandas libraries NOTES: Import NumPy as np and Pandas as pd Given the following piece of code to create a NumPy array,

anIntArray: anIntArray = np.random.randint(5, 72, 48)

Add Python code to convert this array into a Pandas series and then extract values stored at the positions 0, 5, 10, 15, 20 of the series.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

In case of any query do comment. Please rate answer as well. Thanks

Code:

import numpy as np
import pandas as pd
#generate numpy aray
anIntArray = np.random.randint(5, 72, 48)
#convert the array into pandas series
convertedSeries = pd.Series(anIntArray)
#display the desired position data from converted series
print("value at location 0: ", convertedSeries[0])
print("value at location 5: ", convertedSeries[5])
print("value at location 10: ", convertedSeries[10])
print("value at location 15: ", convertedSeries[15])
print("value at location 20: ", convertedSeries[20])

=============screen shot of the code for indentation======

Output:

Add a comment
Know the answer?
Add Answer to:
Problem 2 using Python NumPy and Pandas libraries NOTES: Import NumPy as np and Pandas as...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PYTHON import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.linear_model import...

    PYTHON import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.linear_model import LinearRegression from sklearn.linear_model import LogisticRegression from sklearn.model_selection import train_test_split Our goal is to create a linear regression model to estimate values of ln_price using ln_carat as the only feature. We will now prepare the feature and label arrays. "carat"   "cut" "color"   "clarity"   "depth"   "table"   "price"   "x"   "y"   "z" "1" 0.23   "Ideal" "E" "SI2" 61.5 55 326   3.95   3.98   2.43 "2" 0.21   "Premium" "E" "SI1"...

  • python Problem 3-6 points First, start with the following code: import numpy as np A np.random....

    python Problem 3-6 points First, start with the following code: import numpy as np A np.random. randint (0, 10, sie n,n)) np. savetxt ('exam2.txt', A, fmt-idelimiter B-# np. zeros ( (n, n) , dtypes, int 64, ) When run, it will produce a file named "exam2.txt" that has 5 rows each with 5 numbers separated by commas,. In addition, a 5 by 5 array of zeros named B is defined. Run this code, but do not change it Your job...

  • Python...I don't know what is wrong with my code: import numpy as np from mpi4py import...

    Python...I don't know what is wrong with my code: import numpy as np from mpi4py import MPI array= [14,175, 15,055, 16,616, 17,495, 18,072, 19,390] array1,array2= array[ : :2], array[1: :2] print (array1) print (array2) /////it should print array1 = [1,4175, 16,616,18,072] array2= [15,055, 17,495, 19,390]

  • In Python import numpy as np Given the array a = np.array([[1, 2, 3], [10, 20,...

    In Python import numpy as np Given the array a = np.array([[1, 2, 3], [10, 20, 30], [100, 200, 300]]), compute and print the sums over all rows (should give [6, 60, 600]) the sums over all columns (the sum of he first column is 111) the maximum of the array the maxima over all rows the mean of the sub-array formed by omitting the first row and column the products over the first two columns (hint: look for an...

  • This is my code: import numpy as np import pandas as pd import sys from keras.models...

    This is my code: import numpy as np import pandas as pd import sys from keras.models import Sequential from keras.layers import Dense from sklearn.preprocessing import StandardScaler from keras.layers.normalization import BatchNormalization from keras.layers import Dropout file_full=pd.read_csv("/Users/anwer/Desktop/copy/FULL.csv") file_bottom=pd.read_csv("/Users/anwer/Desktop/copy/bottom.csv") train=[] train_targets=[] test=[] test_targets=[] p=[] q=[]    # We will generate train data using 50% of full data and 50% of bottom data. #is train target for labeling ? yes for train data train_df = file_full[:len(file_full)//2] labels=[ 0 for i in range(len(file_full)//2)] train_df=train_df.append(file_bottom[:len(file_bottom)//2]) for...

  • Before you start For this homework, we will need to import some libraries. You need to...

    Before you start For this homework, we will need to import some libraries. You need to execute the following cell only once; you don't need to copy this in every cell you run. In [ ]: import pandas import numpy from urllib.request import urlretrieve from matplotlib import pyplot %matplotlib inline ​ #This library is needed for testing from IPython.display import set_matplotlib_close set_matplotlib_close(False) Introduction In this homework, you will work with data from the World Bank. The subject of study is...

  • Python 1 import matplotlib.pyplot as plt 2 import numpy as np 3 4 abscissa = np.arange(20) 5 plt....

    python 1 import matplotlib.pyplot as plt 2 import numpy as np 3 4 abscissa = np.arange(20) 5 plt.gca().set_prop_cycle( ’ color ’ , [ ’ red ’ , ’ green ’ , ’ blue ’ , ’ black ’ ]) 6 7 class MyLine: 8 9 def __init__(self, * args, ** options): 10 #TO DO: IMPLEMENT FUNCTION 11 pass 12 13 def draw(self): 14 plt.plot(abscissa,self.line(abscissa)) 15 16 def get_line(self): 17 return "y = {0:.2f}x + {1:.2f}".format(self.slope, self.intercept) 18 19 def __str__(self):...

  • Python with Pandas dataframe I have a csv file that contains a large number of columns...

    Python with Pandas dataframe I have a csv file that contains a large number of columns and rows. I need to write a script that concatenates some elements of the first row with some elements of the 2 row. Something like # if data[1][0] starts with ch then concatenate the element right below it. I have attached a picture of just a sample of my data. The booleans have to stay on there as is. But I must drop the...

  • Python Programming language. Complete the problems below using Jupyter Notebook. Problem Needs to be solved from...

    Python Programming language. Complete the problems below using Jupyter Notebook. Problem Needs to be solved from number #1 link provided for the Data: -----> https://docs.google.com/spreadsheets/d/1TqhyxFKQlOHAyXpQBL-4C96kgZFBoMwUgE8-b33CqPQ/edit?usp=sharing PROBLEMS # 0.0 Import the libraries (pandas, matplotlib, and seaborn) Include the code line: %matplotlib inline #Include the code line: plt.style.use(“ggplot”) #Load the data using pandas #Inspect the data using head(), dtypes ANSWERD: import pandas as pd import matplotlib.pyplot as plt import seaborn as sns plt.style.use('ggplot') %matplotlib inline df = pd.read_csv() print(df.head()) print(df.dtypes) # 1...

  • In python, please code the following: Problem 4 Download the file ATLForecast.dat from canvas. You may...

    In python, please code the following: Problem 4 Download the file ATLForecast.dat from canvas. You may wish to open it to inspect the contents (then close the file to ensure no file locking implications). This file contains the minimum forecast temperature for the next 10 days in Atlanta (I'm waiting for the cool weather to start). Write a program that reads in the contents of this file (see example provided below, usinga function within numpy to read in this text...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT