(Apr-05-2022, 11:55 AM)bnadir55 Wrote: what needs to be changed to accomplish these 2?You most keep the original
df
object an not overwrite it.Example make a own variable when convert to a string,i use perfringo code as example.
>>> df_str = df.to_string(index=False) >>> print(df_str) a b c 0 1 2 3 4 5 6 7 8 >>> >>> # Now still have the original object >>> df a b c 0 0 1 2 1 3 4 5 2 6 7 8 >>> >>> type(df_str) <class 'str'> >>> type(df) <class 'pandas.core.frame.DataFrame'>So when have the original
df
object then it have a method .to_html()
Then the same there without index.
>>> print(df.to_html(index=False)) <table border="1" class="dataframe"> <thead> <tr style="text-align: right;"> <th>a</th> <th>b</th> <th>c</th> </tr> </thead> <tbody> <tr> <td>0</td> <td>1</td> <td>2</td> </tr> <tr> <td>3</td> <td>4</td> <td>5</td> </tr> <tr> <td>6</td> <td>7</td> <td>8</td> </tr> </tbody> </table>