Skip to content

Commit 974985b

Browse files
authored
Merges #64 Closes #64
2 parents 6e69651 + b568f78 commit 974985b

File tree

10 files changed

+202
-176
lines changed

10 files changed

+202
-176
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
runs-on: ubuntu-latest
2323
strategy:
2424
matrix:
25-
python-version: ['3.8', '3.9', '3.10']
25+
python-version: ['3.9', '3.10', '3.11', '3.12']
2626
steps:
2727
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
2828
- name: Download distribution artifact

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
python-version: ['3.8', '3.9', '3.10']
18+
python-version: ['3.9', '3.10', '3.11', '3.12']
1919

2020
name: Python ${{ matrix.python-version }}
2121
steps:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Those are probably a good place to have a look at.
7878

7979
## Requirements
8080

81-
* Python >= 3.8
81+
* Python >= 3.9
8282

8383
You will also need some other libraries for running the tool, you can find the
8484
whole list of dependencies in [pyproject.toml](pyproject.toml) file.

cereslib/dfutils/format.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import pandas
2424

25-
import scipy
25+
import numpy as np
2626

2727

2828
class Format(object):
@@ -53,7 +53,7 @@ def fill_missing_fields(self, data, columns):
5353

5454
for column in columns:
5555
if column not in data.columns:
56-
data[column] = scipy.zeros(len(data))
56+
data[column] = np.zeros(len(data))
5757

5858
return data
5959

cereslib/enrich/enrich.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,14 @@ def enrich(self, column1, column2):
8383
column2 not in self.commits.columns:
8484
return self.commits
8585

86-
# Select rows where values in column1 are different from
87-
# values in column2
88-
pair_df = self.commits[self.commits[column1] != self.commits[column2]]
89-
new_values = list(pair_df[column2])
86+
# Select rows where values in column1 are different from values in column2
87+
pair_df = self.commits[self.commits[column1] != self.commits[column2]].copy()
88+
9089
# Update values from column2
91-
pair_df[column1] = new_values
90+
pair_df[column1] = pair_df[column2].tolist()
9291

93-
# This adds at the end of the original dataframe those rows duplicating
94-
# information and updating the values in column1
95-
return self.commits.append(pair_df)
92+
# Concatenate the original dataframe with the new one
93+
return pandas.concat([self.commits, pair_df], ignore_index=True)
9694

9795

9896
class FileType(Enrich):
@@ -454,14 +452,14 @@ def __remove_surrogates(self, s, method='replace'):
454452
""" Remove surrogates in the specified string
455453
"""
456454

457-
if type(s) == list and len(s) == 1:
455+
if isinstance(s, list) and len(s) == 1:
458456
if self.__is_surrogate_escaped(s[0]):
459457
return s[0].encode('utf-8', method).decode('utf-8')
460458
else:
461459
return ""
462-
if type(s) == list:
460+
if isinstance(s, list):
463461
return ""
464-
if type(s) != str:
462+
if not isinstance(s, str):
465463
return ""
466464
if self.__is_surrogate_escaped(s):
467465
return s.encode('utf-8', method).decode('utf-8')

poetry.lock

Lines changed: 173 additions & 153 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,15 @@ classifiers = [
4141
"Bug Tracker" = "https://github.com/chaoss/grimoirelab-cereslib/issues"
4242

4343
[tool.poetry.dependencies]
44-
python = "^3.8"
44+
python = "^3.9"
4545

46-
numpy = "<1.22.1"
4746
six = "^1.16.0"
4847
scipy = "^1.5"
49-
pandas = "^1.3.5"
48+
pandas = "^2.2"
5049
grimoirelab-toolkit = { version = ">=0.3", allow-prereleases = true }
5150

5251
[tool.poetry.dev-dependencies]
53-
flake8 = "^4.0.1"
52+
flake8 = "^7.1.1"
5453
coverage = "^6.2"
5554

5655
[build-system]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title: Python minimum version updated
3+
category: dependency
4+
author: Jose Javier Merchante <jjmerchante@bitergia.com>
5+
issue: null
6+
notes: >
7+
Python 3.8 will reach its end of life in October 2024.
8+
Python 3.9 is the minimum version required by the project.

tests/test_filter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def test_filter_rows(self):
4040

4141
# One column, values of different types
4242
df = pandas.DataFrame()
43-
filepaths = ['', None, '-', '/file/path', 1, True, pandas.np.nan, '-', [1, 2]]
43+
filepaths = ['', None, '-', '/file/path', 1, True, pandas.NA, '-', [1, 2]]
4444
df["filepath"] = filepaths
4545
data_filtered = FilterRows(df)
4646
df = data_filtered.filter_(["filepath"], "-")

tests/test_format.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
import unittest
2424

2525
import pandas
26-
import scipy
26+
27+
import numpy as np
2728

2829
if '..' not in sys.path:
2930
sys.path.insert(0, '..')
@@ -50,7 +51,7 @@ def test_fill_missing_fields(self):
5051

5152
# With a dataframe with some data, this returns a non-empty dataframe
5253
df = empty_df.copy()
53-
df["test"] = scipy.zeros(10)
54+
df["test"] = np.zeros(10)
5455

5556
self.assertFalse(Format().fill_missing_fields(df, empty_columns).empty)
5657

0 commit comments

Comments
 (0)