BUG: extra leading space in to_string when index=False
State: closed

- [x] closes #24980 , xref #28538
- [x] tests added / passed
- [x] passes `black pandas`
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

I still see people posting issue for the change of behaviour in `to_string(index=False)` on pandas such as #28538 , so I think it might be worth it to reopen my previous stalled PR #25000 and see if could get it solved this time.

All the changes have been made based on the reviews in PR #25000 and for detailed summary and explanation, please check https://github.com/pandas-dev/pandas/pull/25000#issuecomment-458714951
Feel free to take a look and any review and comments are very welcomed!

Labels:
name: Output-Formatting
description: __repr__ of pandas objects, to_string

Comments:
thanks for the pr @charlesdong1991 - some comments above. We can re-open the previous PR if helpful?  #25000
thanks for your comment, @alimcmaster1 
I already have this PR open and there has been dramatic changes since back then, so I think it is fine just to leave the old PR as is. But if you think it's helpful, feel free to re-open the stalled PR, and I don't think I am able to do it.
Finally the annotation error is gone, it's green now 😅 

pls take a look and see if this PR is useful. 
Hello, @jreback 
I would appreciate a lot if you would also like to take a look at this PR which was closed long ago, but since other people posted the issue again, I reopened it with this PR. 

All comments in the last closed PR were addressed.
So, this PR seems ok. Anyone with the right permissions to fix conflict an merge? I've been forced to keep using version `0.23.0`
@simontorres there are quite a number of comments on this
it is not so simple

i find it hard to believe this blocking an update of pandas
I was talking out ignorance. I'm sorry
Hi, @simontorres i resolved the conflict, and as @jreback said, there are some comments in the PR, and pls feel free to take over if you could find a better solution for this, and then i could close this PR to make way for you!
Thanks @charlesdong1991 and @jreback . I don't think I can find a better solution but I will see if I can help.
I am sure you could help with the issue and pandas 👍  @simontorres 

also @jreback feel free to close this PR if you find it hard to approach!
> Thanks @charlesdong1991 and @jreback . I don't think I can find a better solution but I will see if I can help.

@simontorres 
Could you provide a repo of the issue you faced? That way we can ensure we are covering your use case with a test case in pandas.


# Introduction/Application
One example is this Imaging Spectrograph called [GoodmanHTS](http://www.ctio.noao.edu/soar/content/goodman-high-throughput-spectrograph), there are two elements that can move a camera and a dispersor, their angle are recorded in the image's header. There are certain _named modes_ that I'm interested in that can be used define file names, for instance. So this is a shorter version of a longer table.

```python
import pandas

columns = ['grating_freq', 'wavmode', 'camtarg', 'grttarg', 'ob_filter']
spec_mode = [['400', 'm1', '11.6', '5.8', 'None'],
             ['400', 'm2', '16.1', '7.5', 'GG455'],
             ['600', 'UV', '15.25', '7.0', 'None'],
             ['600', 'Blue', '17.0', '7.0', 'None'],
             ['600', 'Mid', '20.0', '10.0', 'GG385'],
             ['600', 'Red', '27.0', '12.0', 'GG495'],
             ['930', 'm1', '20.6', '10.3', 'None'],
             ['930', 'm2', '25.2', '12.6', 'None'],
             ['930', 'm3', '29.9', '15.0', 'GG385'],
             ['930', 'm4', '34.6', '18.3', 'GG495'],
             ['930', 'm5', '39.4', '19.7', 'GG495']]

modes_data_frame = pandas.DataFrame(spec_mode, columns=columns)
```

# The problem

The information I get is the Grating Frequency (for instance 930), the Camera Target Angle (camtarg, 20.6), the  Grating Target Angle (grttarg, 10.3) and the Order Blocking Filter (. When I use pandas to find the match in the following way.

```python
mode = modes_data_frame[
    ((modes_data_frame['grating_freq'] == 930) &
     (modes_data_frame['camtarg'] == 20.6) &
     (modes_data_frame['grttarg'] == 10.3) &
     (modes_data_frame['ob_filter'] == None))]

if mode.empty:
    central_wavelength = get_central_wavelength(*some_args)
    return 'Custom_{:d}nm'.format(central_wavelength)
else:
    return mode['wavmode'].to_string(index=False)
```

it should return 'm1' instead it returns ' m1'
This worked until version 0.23.0 and I reported it on #24980 
This hasn't gotten traction in a while so closing as stale, but @charlesdong1991 or @simontorres ping if you plan to pick up and can continue from there