From mk1853387 at gmail.com Sat Jan 20 14:24:36 2024 From: mk1853387 at gmail.com (marc nicole) Date: Sat, 20 Jan 2024 20:24:36 +0100 Subject: [Pandas-dev] How to replace a cell value with each of its contour cells and yield the corresponding datasets seperately in a list according to a Pandas-way? Message-ID: Hello, I have an initial dataframe with a random list of target cells (each cell being identified with a couple (x,y)). I want to yield four different dataframes each containing the value of one of the contour (surrounding) cells of each specified target cell. the surrounding cells to consider for a specific target cell are : (x-1,y), (x,y-1),(x+1,y);(x,y+1), specifically I randomly choose 1 to 4 cells from these and consider for replacement to the target cell. I want to do that through a pandas-specific approach without having to define the contour cells separately and then apply the changes on the dataframe (but rather using an all in one approach): for now I have written this example which I think is not Pandas specific: *def select_target_values(dataframe, number_of_target_values): target_cells = [] for _ in range(number_of_target_values): row_x = random.randint(0, len(dataframe.columns) - 1) col_y = random.randint(0, len(dataframe) - 1) target_cells.append((row_x, col_y)) return target_cellsdef select_contours(target_cells): contour_coordinates = [(0, 1), (1, 0), (0, -1), (-1, 0)] contour_cells = [] for target_cell in target_cells: # random contour count for each cell contour_cells_count = random.randint(1, 4) try: contour_cells.append( [tuple(map(lambda i, j: i + j, (target_cell[0], target_cell[1]), contour_coordinates[iteration_])) for iteration_ in range(contour_cells_count)]) except IndexError: continue return contour_cells def apply_contours(target_cells, contour_cells): target_cells_with_contour = [] # create one single list of cells for idx, target_cell in enumerate(target_cells): target_cell_with_contour = [target_cell] target_cell_with_contour.extend(contour_cells[idx]) target_cells_with_contour.append(target_cell_with_contour) return target_cells_with_contour def create_possible_datasets(dataframe, target_cells_with_contour): all_datasets_final = [] dataframe_original = dataframe.copy() #check for nans list_tuples_idx_cells_all_datasets = list(filter(lambda x: utils_tuple_list_not_contain_nan(x), [list(tuples) for tuples in list(itertools.product( *target_cells_with_contour))])) target_original_cells_coordinates = list(map(lambda x: x[0], [target_and_contour_cell for target_and_contour_cell in target_cells_with_contour])) for dataset_index_values in list_tuples_idx_cells_all_datasets: all_datasets = [] for idx_cell in range(len(dataset_index_values)): dataframe_cpy = dataframe.copy() dataframe_cpy.iat[ target_original_cells_coordinates[idx_cell][1], target_original_cells_coordinates[idx_cell][ 0]] = dataframe_original.iloc[dataset_index_values[idx_cell][1], dataset_index_values[idx_cell][0]] all_datasets.append(dataframe_cpy) all_datasets_final.append(all_datasets) return all_datasets_final* If you have a better Pandas approach (unifying all these methods into one that make use of dataframe methods only) please let me know. thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: From rhshadrach at gmail.com Sun Jan 21 04:48:45 2024 From: rhshadrach at gmail.com (Richard Shadrach) Date: Sun, 21 Jan 2024 04:48:45 -0500 Subject: [Pandas-dev] How to replace a cell value with each of its contour cells and yield the corresponding datasets seperately in a list according to a Pandas-way? In-Reply-To: References: Message-ID: Hi Marc, This email list is for developers and contributors to the pandas package itself, rather than pandas users. I would recommend posting your question to Stack Overflow. If you don't get any satisfactory answers there, then you're welcome to open up a Usage Question on the pandas issue tracker at https://github.com/pandas-dev/pandas/issues. Best, Richard On Sat, Jan 20, 2024 at 2:22?PM marc nicole wrote: > Hello, > > I have an initial dataframe with a random list of target cells (each cell > being identified with a couple (x,y)). > I want to yield four different dataframes each containing the value of one > of the contour (surrounding) cells of each specified target cell. > > the surrounding cells to consider for a specific target cell are : > (x-1,y), (x,y-1),(x+1,y);(x,y+1), specifically I randomly choose 1 to 4 > cells from these and consider for replacement to the target cell. > > I want to do that through a pandas-specific approach without having to > define the contour cells separately and then apply the changes on the > dataframe (but rather using an all in one approach): > for now I have written this example which I think is not Pandas specific: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > *def select_target_values(dataframe, number_of_target_values): > target_cells = [] for _ in range(number_of_target_values): row_x > = random.randint(0, len(dataframe.columns) - 1) col_y = > random.randint(0, len(dataframe) - 1) target_cells.append((row_x, > col_y)) return target_cellsdef select_contours(target_cells): > contour_coordinates = [(0, 1), (1, 0), (0, -1), (-1, 0)] contour_cells = > [] for target_cell in target_cells: # random contour count for > each cell contour_cells_count = random.randint(1, 4) try: > contour_cells.append( [tuple(map(lambda i, j: i + j, > (target_cell[0], target_cell[1]), contour_coordinates[iteration_])) > for iteration_ in range(contour_cells_count)]) except > IndexError: continue return contour_cells def > apply_contours(target_cells, contour_cells): target_cells_with_contour = > [] # create one single list of cells for idx, target_cell in > enumerate(target_cells): target_cell_with_contour = [target_cell] > target_cell_with_contour.extend(contour_cells[idx]) > target_cells_with_contour.append(target_cell_with_contour) return > target_cells_with_contour def create_possible_datasets(dataframe, > target_cells_with_contour): all_datasets_final = [] > dataframe_original = dataframe.copy() #check for nans > list_tuples_idx_cells_all_datasets = list(filter(lambda x: > utils_tuple_list_not_contain_nan(x), > [list(tuples) for tuples in list(itertools.product( > > *target_cells_with_contour))])) target_original_cells_coordinates = > list(map(lambda x: x[0], > [target_and_contour_cell for target_and_contour_cell in > target_cells_with_contour])) for > dataset_index_values in list_tuples_idx_cells_all_datasets: > all_datasets = [] for idx_cell in range(len(dataset_index_values)): > dataframe_cpy = dataframe.copy() dataframe_cpy.iat[ > target_original_cells_coordinates[idx_cell][1], > target_original_cells_coordinates[idx_cell][ 0]] = > dataframe_original.iloc[dataset_index_values[idx_cell][1], > dataset_index_values[idx_cell][0]] > all_datasets.append(dataframe_cpy) > all_datasets_final.append(all_datasets) return all_datasets_final* > > > If you have a better Pandas approach (unifying all these methods into one > that make use of dataframe methods only) please let me know. > > thanks! > > > _______________________________________________ > Pandas-dev mailing list > Pandas-dev at python.org > https://mail.python.org/mailman/listinfo/pandas-dev > -------------- next part -------------- An HTML attachment was scrubbed... URL: From li.thomas3124 at gmail.com Mon Jan 22 13:08:49 2024 From: li.thomas3124 at gmail.com (Thomas Li) Date: Mon, 22 Jan 2024 10:08:49 -0800 Subject: [Pandas-dev] ANN: pandas v2.2.0 Message-ID: We are pleased to announce the release of pandas 2.2.0. This release includes some new features, bug fixes, and performance improvements. We recommend that all users upgrade to this version. See the [full whatsnew](https://pandas.pydata.org/pandas-docs/version/2.2 .0/whatsnew/v2.2.0.html) for a list of all the changes. Pandas 2.2.0 supports Python 3.9 and higher. The release will be available on the defaults and conda-forge channels: conda install pandas Or via PyPI: python3 -m pip install --upgrade pandas Please report any issues with the release on the [pandas issue tracker]( https://github.com/pandas-dev/pandas/issues). Thanks to all the contributors who made this release possible. -------------- next part -------------- An HTML attachment was scrubbed... URL: From deamarialeon at gmail.com Tue Jan 23 08:34:11 2024 From: deamarialeon at gmail.com (=?UTF-8?Q?Dea_Mar=C3=ADa?=) Date: Tue, 23 Jan 2024 14:34:11 +0100 Subject: [Pandas-dev] Conbench PoC - benchmarks Message-ID: Hi All, I have been working on a PoC to use conbench with pandas asv benchmarks, and it is ready to be reviewed. The setup is ready to start sending regression/improvement alerts by email. An email group will be created soon where those of you who are interested can subscribe. I shared a document on Slack that includes a quick user guide. Or it can be seen here: https://drive.google.com/file/d/1xTrLbocmKBoHtRzvBNUMJGTnxojRh_Sp/view?usp=sharing The link to the PoC is here: http://57.128.112.95:5000/ I look forward to hearing your thoughts. Dea -------------- next part -------------- An HTML attachment was scrubbed... URL: From ganesh24 at purdue.edu Mon Jan 29 01:53:09 2024 From: ganesh24 at purdue.edu (Ganesh, Sriram) Date: Mon, 29 Jan 2024 06:53:09 +0000 Subject: [Pandas-dev] OSS Validation and Verification Project Assistance Message-ID: Good Evening, I am currently part of a team of students involved in an OSS Validation and Verification Project as part of an Advanced Software Engineering Graduate class at Purdue University. We were tasked with picking an OSS, and finding defects such as (1)overhauling a test suite; or (2) applying some state-of the art techniques to the project. We are specifically interested in pandas. Our goal is to address issues identifying and addressing bugs, vulnerabilities, and security holes through testing and validation. We have looked at the list of issues provided at https://github.com/pandas-dev/pandas/issues. Is there any specific issue that you would like looked at as part of this Project? Ideally this would be something we accomplish with a two month timeframe, but we are flexible. We are open to any suggestions on issues to look into and open to chat as well. Thanks for the help! Thanks, Sriram Ganesh BS Purdue ME 23' MS Purdue ME 25' e: ganesh24 at purdue.edu -------------- next part -------------- An HTML attachment was scrubbed... URL: