Skip to content

Commit

Permalink
Update t2df.m
Browse files Browse the repository at this point in the history
  • Loading branch information
Lenskiy authored May 26, 2022
1 parent 582498c commit e56cbe3
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions t2df.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
else
column = tab(:,k).Variables;
end
% Tables are allowed to have two columns under othe same name.
% Hence, iterate over subcolumns and split them to different
% columns
% Tables are allowed to have a few columns with the same name.
% Hence, iterate over subcolumns and split them into different
% columns so Dataframe can be created
for l = 1:size(column, 2)
if matches(types{k}, 'cell')
if(size(column(:,l), 1) ~= 1)
Expand All @@ -22,16 +22,12 @@
pandasColumn = py.pandas.DataFrame(column(:,l).cellstr, columns = {names{k}}, dtype="string");
end
elseif matches(types{k}, 'logical')
%pandasColumn = py.pandas.DataFrame(int64(column(:,l)), columns = {names{k}}, dtype="bool");
pandasColumn = py.pandas.DataFrame(arrayfun(@(x) py.bool(x), column(:,l), 'UniformOutput', false)', columns = {names{k}}, dtype="bool");
elseif contains(types{k}, 'int')
%pandasColumn = py.pandas.DataFrame(column(:,l), columns = {names{k}}, dtype=types{k});
pandasColumn = py.pandas.DataFrame(arrayfun(@(x) py.int(x), column(:,l), 'UniformOutput', false)', columns = {names{k}}, dtype=types{k});
elseif matches(types{k}, 'char') || matches(types{k}, 'string')
%pandasColumn = py.pandas.DataFrame(column(:,l), columns = {names{k}}, dtype="string");
pandasColumn = py.pandas.DataFrame(arrayfun(@(x) py.str(x), column(:,l), 'UniformOutput', false)', columns = {names{k}}, dtype="string");
elseif matches(types{k}, 'double') || matches(types{k}, 'float')
% pandasColumn = py.pandas.DataFrame(column(:,l), columns = {names{k}}, dtype="float");
pandasColumn = py.pandas.DataFrame(arrayfun(@(x) py.float(x), column(:,l), 'UniformOutput', false)', columns = {names{k}}, dtype="float");

else
Expand Down

0 comments on commit e56cbe3

Please sign in to comment.