Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions biopandas/pdb/pandas_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ def _construct_df(pdb_lines):
except ValueError:
# expect ValueError if float/int columns are empty strings
df[c["id"]] = pd.Series(np.nan, index=df.index)
df["line_idx"] = df["line_idx"].astype(np.int64)

dfs[r[0]] = df

Expand Down
2 changes: 2 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ The CHANGELOG for the current development version is available at

- Fix: `PandasPdb.to_pdb()` no longer fails with a `TypeError` on structures with `ANISOU` records after `label_models()`. The `model_id` column is now skipped silently, like in `to_pdb_stream()`, and other unexpected `ANISOU` columns are skipped with a warning, as for `ATOM` and `HETATM`. Addresses issue [#124](https://github.com/BioPandas/biopandas/issues/124).

- Fix: `line_idx` is now `int64` in empty record DataFrames (e.g. `ANISOU` for a file without anisotropic records) instead of `object`, matching non-empty frames. Addresses issue [#64](https://github.com/BioPandas/biopandas/issues/64).

### 0.5.2 (24/08/2026)

- Fix: improves robustness of `amino3to1` residue identification by handling `NaN` insertion codes (NumPy 2.4+ compatibility) and including chain IDs and separators to avoid collisions. PR [#157](https://github.com/BioPandas/biopandas/pull/157)
Expand Down
8 changes: 8 additions & 0 deletions tests/pdb/test_read_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,14 @@ def test_read_pdb_from_list():
assert ppdb.pdb_path == ""


def test_line_idx_dtype_for_empty_records():
ppdb = PandasPdb()
ppdb.read_pdb(TESTDATA_FILENAME)
assert ppdb.df["ANISOU"].empty
for record in ("ATOM", "HETATM", "ANISOU", "OTHERS"):
assert ppdb.df[record]["line_idx"].dtype == np.int64


def test_anisou_input_handling():
"""Test public read_pdb"""
ppdb = PandasPdb()
Expand Down
Loading