append Series
This commit is contained in:
parent
aeec0fa66a
commit
d95de80f58
|
|
@ -21,7 +21,7 @@ def load_ods(doc, sheet, headers=True, columns=None):
|
|||
# row is a list of cells
|
||||
if headers and i == 0 and not columns:
|
||||
# columns as lists in a dictionary
|
||||
df_dict = {cell.value: [] for cell in row if cell.value}
|
||||
df_dict = {cell.value: pd.Series() for cell in row if cell.value}
|
||||
# create index for the column headers
|
||||
col_index = {
|
||||
j: cell.value for j, cell in enumerate(row) if cell.value}
|
||||
|
|
@ -30,7 +30,7 @@ def load_ods(doc, sheet, headers=True, columns=None):
|
|||
columns = columns if columns else (
|
||||
["column_%s" % j for j in range(len(row))])
|
||||
# columns as lists in a dictionary
|
||||
df_dict = {column: pd.Series([] for column in columns)}
|
||||
df_dict = {column: pd.Series() for column in columns}
|
||||
# create index for the column headers
|
||||
col_index = {j: column for j, column in enumerate(columns)}
|
||||
if headers:
|
||||
|
|
@ -38,7 +38,7 @@ def load_ods(doc, sheet, headers=True, columns=None):
|
|||
for j, cell in enumerate(row):
|
||||
if j < len(col_index):
|
||||
# use header instead of column index
|
||||
df_dict[col_index[j]].append(cell.value)
|
||||
df_dict[col_index[j]].append(pd.Series([cell.value]))
|
||||
else:
|
||||
continue
|
||||
# and convert to a DataFrame
|
||||
|
|
|
|||
Loading…
Reference in New Issue