Category "numpy"

NumPy Slicing HackerRank

I have wrote a function named array_slice which gets four numbers n, n_dim, n_row, n_col from the user and performs array operations given below. Instructions:

What is the problem in this keras input shape?

from matplotlib import units import numpy as np from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense from tensorflow.keras

Convert list of objects to numpy array without coercing objects into array

I want to turn a Python list of objects into a numpy array of objects for easier manipulation of the list, e.g. index slicing, etc. However, numpy coerces list-

Generate multiple new pandas dataframes using lists and for loops

I have the following dataframe: import pandas as pd import numpy as np from numpy import rec, nan df1=pd.DataFrame.from_records(rec.array([(202001L, 2020L, 'app

RankWarning: Polyfit may be poorly conditioned

I am trying to find the rolling price slope of btc trading data (minute data) using pandas. When I run the script, the following error / warning pops up sys:1:

RankWarning: Polyfit may be poorly conditioned

I am trying to find the rolling price slope of btc trading data (minute data) using pandas. When I run the script, the following error / warning pops up sys:1:

Using multi character delimiter while exporting SQL table as text file using python

I am trying to export SQL table as multi-character delimited text file in python. I have tried using Pandas, but it is only supporting single character as delim

how do I find the average of this array but only for the values that are not equal to zero in python [duplicate]

array([1500, 1520, 1540, 1590, 1590, 1600, 1600, 1560, 1560, 1560, 1580, 1520, 1460, 1510, 1520, 1320, 1320, 1300, 1300, 1320, 1320, 1320, 132

How to use pandas and numpy to compare two excel workbooks with multiple tabs?

I have two xlsx files that have multiple tabs. I need to compare values in each tab based on the tab name. (e.g. sheet1 in file1 needs to be compared with sheet

Pandas column-wise rolling works with np.float64 but returns empty array with np.float32 and np.float16

I ran into a strange observation where the same code works with np.float64 but not with np.float32 or np.float16. Here's code to reproduce the results: >>

Can't pip install scipy on M1

I can't "pip instal scipy" on my m1 mac, I get an error: Collecting scipy Using cached scipy-1.7.3.tar.gz (36.1 MB) Installing build dependencies ... error

Adding Pandas column in custom function not working when using numpy

I have the following function: def create_col4(df): df['col4'] = df['col1'] + df['col2'] If I apply this function within my jupyter notebook as in create_c

Round number down to the next 1000 in python [duplicate]

can somebody tell me how i can round down to the nearest thousand. So far I tried it with math.round(), the truncate function but i couldn't f

Will Numpy wheels for python 3.10 32 bits be available

First I asked on gitter, though I got help they were not sure, see link Numpy release v1.21.3 states: Note a few oddities about Python 3.10: There are no 32 bi

Error in Jupyter notebook even after importing the required library

I'm getting an NameError in jupyter notebook even after importing numpy as np. Any idea how to go about it will be appreciated %matplotlib inline %config Inline

Reshape of dataset (Time Series) after filtering?

i am using HampelFilter to detect outliers by SKTIME on my dataset but i faced a problem after applied the filter . My dataset contains Timeseries (signals) the

Python: Formatting a Pandas dataframe head with LaTex

I have made a Pandas dataframe from several NumPy arrays and tried to format columns heads using LaTex, but it looks awful. I'm working with Jupyter Notebook. i

Forming a 3D np array from a 2D array

Let's say I have a 2D array: L = np.array([[1,2,3], [4,5,6], [7,8,9]]) I would like to make a 3D array from this, using a parameter

Problem with python while loop going over every element in 2d array

I am having problems with while loops in python right now: while(j < len(firstx)): trainingset[j][0] = firstx[j] trainingset[j][1] = firsty[j] tr

ValueError: operands could not be broadcast together with shapes (120,) (6,)

So this is my python code import numpy as np n = 3 T = 100 ts = .2*(100/(2*n-3))