0

Just wanted to add space either side to all cell content in DataFrame and needs to be Right aligned. [Input Format Each column with Tab Space][1] [1]: https://i.stack.imgur.com/MM7e0.png

[Output Format with Each column needs to be separated with 5 spaces and right aligned][2] [2]: https://i.stack.imgur.com/unc6B.png

I tried with Str.pad ( its applicable for Strings and prefix applicable only for Headers)

Thanks in advance

1 Answers1

1

Look into numpy.linspace and also see the example here. You can also manually do this by doing the following, for example:

with open(filename, 'r') as f: 
    in_lines = f.readlines()
with open(outfile, 'w') as f:
    eight_spaces = '        '
    for line in in_lines:
        split_line = line.split()
        out_line = eight_spaces.join(split_line)
        f.write(out_line + '\n')
AzyCrw4282
  • 7,222
  • 5
  • 19
  • 35