Question

Using Python - Pandas and Numpy Data Structures: *use np.randint create 2 columns of 10 random...

Using Python - Pandas and Numpy Data Structures:

*use np.randint create 2 columns of 10 random numbers from dataframe

*Code for creating and printing a 2 by 3 numpy array of random numbers

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

1)answer)*use np.randint create 2 columns of 10 random numbers from dataframe

import pandas

import numpy

dataframe = pandas.DataFrame(numpy.random.randint(0,1000,size=(5, 2)), columns=['Column1','Column2'])

print(dataframe)

here random number are for 0 to 1000.1000 is excluded.

here Column1 and Column2 are columns of dataframe

size=(5,2) represents 5 rows and 2 columns

2)answer)

*Code for creating and printing a 2 by 3 numpy array of random numbers

import numpy

matrix = numpy.random.random((2,4))

print(matrix)

output:

[[0.59318327 0.9456122 0.7911109 0.21969092]
[0.24625455 0.20927113 0.9708574 0.85175868]]

Add a comment
Know the answer?
Add Answer to:
Using Python - Pandas and Numpy Data Structures: *use np.randint create 2 columns of 10 random...
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
  • 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.

  • do it in python 1. Import the proper libraries: Pandas and NumPy and create aliases pd,...

    do it in python 1. Import the proper libraries: Pandas and NumPy and create aliases pd, np respectively. 2. Load sample data (car_loan.csv) into data frame: df 3. Export Pandas DataFrames to csv. Save file name as out.csv. hint: help(df.to_csv) 4. Run the command: df.info (). What do you see, how many columns? also what about number of entries for each column 5. It is often the case where you change your column names or remove unnecessary columns. a. Change...

  • (a) Load the data file data/tips.csv into a pandas DataFrame called tips_df using the pandas read_table()...

    (a) Load the data file data/tips.csv into a pandas DataFrame called tips_df using the pandas read_table() function. Check the first five rows. (b) Create a new dataframe called tips by randomly sampling 6 records from the dataframe tips_df. Refer to the sample() function documentation. (c) Add a new column to tips called idx as a list ['one', 'two', 'three', 'four', 'five', 'six'] and then later assign it as the index of tips dataframe. Display the dataframe. (d) Create a new...

  • Using Python please create a code that #Use NumPy and MatPlotLib to create a plot of...

    Using Python please create a code that #Use NumPy and MatPlotLib to create a plot of f(x) = x**4 + 10 # in the range x=(-10, 10) (inclusive), with a point on the plot every 0.5 change in x. # Include the correct import statements

  • need help with this python progam using numpy Create a 4x4 two dimensional array with numbers...

    need help with this python progam using numpy Create a 4x4 two dimensional array with numbers from 1 thru 16. show this then: Change the last element by dividing it in half. Show that the original array has changed. show this then: Set all values in row 2 to zero. Show the original array contains this change show this then: Set all values in column 1 to one. Shoe the original array contains this change. show this then: Display the...

  • Python NumPy Create an NumPy array and a print statement that will produce the following output...

    Python NumPy Create an NumPy array and a print statement that will produce the following output when your code runs: array: ['1' '2'] and its dtype is: |S1 What type is "s1"? (answer via a print statement in your code).

  • PYTHON: I have a numpy array that holds a name and a phone number such as...

    PYTHON: I have a numpy array that holds a name and a phone number such as this one. import numpy as np import pandas as pd LIST = np.array([("James", "Kirk", "512-375-5585"), ("Richard", "Branson, "1234567890"), ("James", "Bond", "34567")]) Then I stuff it into a data frame by doing this df = pd.DataFrame(List, columns=('Firstname', 'Lastname', 'Phone')) How would I go about changing 10 digit phone numbers such as 1234567890 into 123-456-7890 and discarding invalid ones such as 34567 so it reflects in...

  • 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...

  • PLEASE USE PYTHON*** 11.2 Create a numpy array with values 10, 11, ..., 49 and give...

    PLEASE USE PYTHON*** 11.2 Create a numpy array with values 10, 11, ..., 49 and give it to a variable named var. Then print out var

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