Skip to main content

All Questions

Tagged with
2 votes
2 answers
62 views

Pandas: Fill in missing values with an empty numpy array

I have a Pandas Dataframe that I derive from a process like this: df1 = pd.DataFrame({'c1':['A','B','C','D','E'],'c2':[1,2,3,4,5]}) df2 = pd.DataFrame({'c1':['A','B','C'],'c2':[1,2,3],'c3': [np.array((...
cbw's user avatar
  • 289
0 votes
3 answers
40 views

How to multiply the elements of an array to the corresponding elements of a set of DataFrames?

How do I multiply the elements of an array to the corresponding elements of a set of DataFrames? My matrices are quite large, but for the sake of simplicity I will use only a 2x3 dimension: For ...
user23487612's user avatar
0 votes
2 answers
72 views

How to convert string scientific notation to float within a txt file

I have code in a .txt file that has scientific notation values stored as strings and I am trying to convert them to floats that way I can perform calculations on them. However, when I try to attempt ...
n00bcoder_24's user avatar
0 votes
2 answers
49 views

How to copy values between 2 dataframes based on similar/matching items in multiple columns? [duplicate]

I have 2 dataframes (df1 and df2) and they look like this: df1 index gameID Team A B C 0 0001 Lakers 10 100 90 1 0001 Clippers 20 105 91 2 ...
Noki's user avatar
  • 1
0 votes
2 answers
47 views

Create Pivot table and add additional columns from another dataframe

Given two identically formatted dataframes: df1 Counterparty Product Deal Date Value foo bar Buy 01/01/24 10.00 foo bar Buy 01/01/24 10.00 foo ...
iBeMeltin's user avatar
  • 1,885
0 votes
2 answers
53 views

Extracting wrapped column data

I have a particular data file that has 7 columns total: 1 column of time and 6 columns of data. As depicted in the image I attached, the first column represents time, while the next four columns ...
kowalski's user avatar
  • 151
0 votes
1 answer
55 views

Is there a way to compute this table in Python?

I'm having trouble computing this table in python since the x-axis and y-axis have ranges. Is there a way I can input this table without manually putting in all numbers within the ranges? For example, ...
Mayah's user avatar
  • 1
0 votes
0 answers
111 views

ADTK Visualization: ValueError: Multi-dimensional indexing (e.g. `obj[:, None]`) is no longer supported

I have tried to reproduce the examples from anomaly detection tutorial: https://adtk.readthedocs.io/en/stable/notebooks/demo.html#ThresholdAD When I use this to plot: from adtk.visualization import ...
Arseniy Sleptsov's user avatar
0 votes
4 answers
109 views

Efficient way to iterate rows in two arrays and then copy array back into a dataframe

I am learning numpy and I have a dataframe of asset prices and thought it might be better to do a calculation in numpy and then put the data back into a dataframe when done. I have a working program ...
chirob's user avatar
  • 91
1 vote
1 answer
59 views

How to split an array using its minimum entry

I am trying to split a dataset into two separate ones by finding its minimum point in the first column. I have used idxmin to firstly identify the location of the minimum entry and secondly iloc to ...
John278's user avatar
  • 25
1 vote
1 answer
77 views

Adding numpy arrays to cells of a pandas DataFrame depends on initialisation

I was trying to add a list of numpy arrays as elements to the pandas DataFrame: DataFrame using: df.loc[df['B']==4,'A'] = [np.array([5, 6, 7, 8]),np.array([2,3])] Whether or not this is allowed seems ...
Anita Karsa's user avatar
0 votes
2 answers
79 views

Sum cell values below until a blank cell with Python

I am looking for a Python code that enables me to sum all the values within a column (e.g. Column A) until a blank cell is reached. This process should then repeat itself until the end of the column. ...
Megan Lee's user avatar
0 votes
2 answers
106 views

How to find first value from an array column which matches a substring in a different column? PySpark

I'm trying to select the first instance of an element in an array column which matches a substring in a different column, and then create a different column with the selected element, like this: col_a ...
mushroom_grl's user avatar
0 votes
4 answers
97 views

Build Pandas DataFrame from a list array with new column as list names

I would like to convert a list of arrays of varying array shapes like this: import numpy as np import pandas as pd data = [np.array([[1, 2, 3], [1, 3, 2], [1, 1, 2]]), np.array([[1, 3, 3], [2,...
goingecho's user avatar
-3 votes
1 answer
139 views

Error when dividing DataFrame values by 255 in Python

I am encountering a TypeError when attempting to normalize the values in a pandas DataFrame by dividing them by 255 in Python. The error message is as follows: TypeError: unsupported operand type(s) ...
nesly's user avatar
  • 58

15 30 50 per page
1
2 3 4 5
42