Skip to content

Commit c93b21a

Browse files
committed
7 elif changed
1 parent 56807fe commit c93b21a

File tree

7 files changed

+53
-54
lines changed

7 files changed

+53
-54
lines changed

pandas/io/formats/format.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,11 +2103,11 @@ def __call__(self, num: float) -> str:
21032103

21042104
if self.use_eng_prefix:
21052105
prefix = self.ENG_PREFIXES[int_pow10]
2106+
2107+
elif int_pow10 < 0:
2108+
prefix = f"E-{-int_pow10:02d}"
21062109
else:
2107-
if int_pow10 < 0:
2108-
prefix = f"E-{-int_pow10:02d}"
2109-
else:
2110-
prefix = f"E+{int_pow10:02d}"
2110+
prefix = f"E+{int_pow10:02d}"
21112111

21122112
mant = sign * dnum / (10**pow10)
21132113

pandas/io/formats/info.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -660,14 +660,14 @@ def _create_table_builder(self) -> DataFrameTableBuilder:
660660
)
661661
elif self.verbose is False: # specifically set to False, not necessarily None
662662
return DataFrameTableBuilderNonVerbose(info=self.info)
663+
664+
elif self.exceeds_info_cols:
665+
return DataFrameTableBuilderNonVerbose(info=self.info)
663666
else:
664-
if self.exceeds_info_cols:
665-
return DataFrameTableBuilderNonVerbose(info=self.info)
666-
else:
667-
return DataFrameTableBuilderVerbose(
668-
info=self.info,
669-
with_counts=self.show_counts,
670-
)
667+
return DataFrameTableBuilderVerbose(
668+
info=self.info,
669+
with_counts=self.show_counts,
670+
)
671671

672672

673673
class SeriesInfoPrinter(InfoPrinterAbstract):

pandas/io/formats/printing.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,10 @@ class TableSchemaFormatter(BaseFormatter):
272272
formatters[mimetype] = TableSchemaFormatter()
273273
# enable it if it's been disabled:
274274
formatters[mimetype].enabled = True
275-
else:
276-
# unregister tableschema mime-type
277-
if mimetype in formatters:
278-
formatters[mimetype].enabled = False
275+
276+
# unregister tableschema mime-type
277+
elif mimetype in formatters:
278+
formatters[mimetype].enabled = False
279279

280280

281281
def default_pprint(thing: Any, max_seq_items: int | None = None) -> str:

pandas/io/parquet.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,8 @@ def validate_dataframe(df: DataFrame) -> None:
131131
each level of the MultiIndex
132132
"""
133133
)
134-
else:
135-
if df.columns.inferred_type not in {"string", "empty"}:
136-
raise ValueError("parquet must have string column names")
134+
elif df.columns.inferred_type not in {"string", "empty"}:
135+
raise ValueError("parquet must have string column names")
137136

138137
# index level names must be strings
139138
valid_names = all(

pandas/io/parsers/c_parser_wrapper.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -394,26 +394,26 @@ def _concatenate_chunks(chunks: list[dict[int, ArrayLike]]) -> dict:
394394
dtype = dtypes.pop()
395395
if is_categorical_dtype(dtype):
396396
result[name] = union_categoricals(arrs, sort_categories=False)
397+
398+
elif isinstance(dtype, ExtensionDtype):
399+
# TODO: concat_compat?
400+
array_type = dtype.construct_array_type()
401+
# error: Argument 1 to "_concat_same_type" of "ExtensionArray"
402+
# has incompatible type "List[Union[ExtensionArray, ndarray]]";
403+
# expected "Sequence[ExtensionArray]"
404+
result[name] = array_type._concat_same_type(
405+
arrs # type: ignore[arg-type]
406+
)
397407
else:
398-
if isinstance(dtype, ExtensionDtype):
399-
# TODO: concat_compat?
400-
array_type = dtype.construct_array_type()
401-
# error: Argument 1 to "_concat_same_type" of "ExtensionArray"
402-
# has incompatible type "List[Union[ExtensionArray, ndarray]]";
403-
# expected "Sequence[ExtensionArray]"
404-
result[name] = array_type._concat_same_type(
405-
arrs # type: ignore[arg-type]
406-
)
407-
else:
408-
# error: Argument 1 to "concatenate" has incompatible
409-
# type "List[Union[ExtensionArray, ndarray[Any, Any]]]"
410-
# ; expected "Union[_SupportsArray[dtype[Any]],
411-
# Sequence[_SupportsArray[dtype[Any]]],
412-
# Sequence[Sequence[_SupportsArray[dtype[Any]]]],
413-
# Sequence[Sequence[Sequence[_SupportsArray[dtype[Any]]]]]
414-
# , Sequence[Sequence[Sequence[Sequence[
415-
# _SupportsArray[dtype[Any]]]]]]]"
416-
result[name] = np.concatenate(arrs) # type: ignore[arg-type]
408+
# error: Argument 1 to "concatenate" has incompatible
409+
# type "List[Union[ExtensionArray, ndarray[Any, Any]]]"
410+
# ; expected "Union[_SupportsArray[dtype[Any]],
411+
# Sequence[_SupportsArray[dtype[Any]]],
412+
# Sequence[Sequence[_SupportsArray[dtype[Any]]]],
413+
# Sequence[Sequence[Sequence[_SupportsArray[dtype[Any]]]]]
414+
# , Sequence[Sequence[Sequence[Sequence[
415+
# _SupportsArray[dtype[Any]]]]]]]"
416+
result[name] = np.concatenate(arrs) # type: ignore[arg-type]
417417

418418
if warning_columns:
419419
warning_names = ",".join(warning_columns)

pandas/io/parsers/python_parser.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -555,20 +555,20 @@ def _infer_columns(
555555
columns = self._handle_usecols(
556556
columns, columns[0], num_original_columns
557557
)
558-
else:
559-
if self.usecols is None or len(names) >= num_original_columns:
560-
columns = self._handle_usecols([names], names, num_original_columns)
561-
num_original_columns = len(names)
562-
else:
563-
if not callable(self.usecols) and len(names) != len(self.usecols):
564-
raise ValueError(
565-
"Number of passed names did not match number of "
566-
"header fields in the file"
567-
)
568-
# Ignore output but set used columns.
569-
self._handle_usecols([names], names, ncols)
570-
columns = [names]
571-
num_original_columns = ncols
558+
559+
elif self.usecols is None or len(names) >= num_original_columns:
560+
columns = self._handle_usecols([names], names, num_original_columns)
561+
num_original_columns = len(names)
562+
563+
elif not callable(self.usecols) and len(names) != len(self.usecols):
564+
raise ValueError(
565+
"Number of passed names did not match number of "
566+
"header fields in the file"
567+
)
568+
# Ignore output but set used columns.
569+
self._handle_usecols([names], names, ncols)
570+
columns = [names]
571+
num_original_columns = ncols
572572

573573
return columns, num_original_columns, unnamed_cols
574574

pandas/io/pytables.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2196,9 +2196,9 @@ def update_info(self, info) -> None:
21962196
f"existing_value [{existing_value}] conflicts with "
21972197
f"new value [{value}]"
21982198
)
2199-
else:
2200-
if value is not None or existing_value is not None:
2201-
idx[key] = value
2199+
2200+
elif value is not None or existing_value is not None:
2201+
idx[key] = value
22022202

22032203
def set_info(self, info) -> None:
22042204
"""set my state from the passed info"""

0 commit comments

Comments
 (0)