0

I have the following code where I'm printing out some data from seaborn

# import library
import seaborn
import seaborn as sns
import pandas as pd
import numpy as np

data_list = sns.get_dataset_names()

# make new table to store only the numerical features
# of a given dataset
num_data = []

# display first 5 rows of original dataset and new dataset
# containing only numerically selected features
for item in data_list:
    df = seaborn.load_dataset("{}".format((item)))
    print("Dataset Title - {}".format(item.capitalize()))
    print()

    # original dataset
    pd.set_option('display.max_columns', None)
    print(df.head())
    print()

    # numerical dataset
    num_data = df.select_dtypes(include='number')
    print(num_data.head())
    print()

and when I run this, in my Python Console (running Pycharm)

Dataset Title - Brain_networks

  network                  1                1.1                   2  \
0    node                  1                  1                   1   
1    hemi                 lh                 rh                  lh   
2     NaN                NaN                NaN                 NaN   
3       0  56.05574417114258  92.03103637695312   3.391575574874878   
4       1   55.5472526550293   43.6900749206543  -65.49598693847656   
                   2.1                   3                 3.1  \
0                    1                   1                   1   
1                   rh                  lh                  rh   
2                  NaN                 NaN                 NaN   
3    38.65968322753906  26.203819274902344  -49.71556854248047   
4  -13.974522590637207  -28.27496337890625  -39.05012893676758   
                     4                  4.1                    5  \
0                    1                    1                    1   
1                   lh                   rh                   lh   
2                  NaN                  NaN                  NaN   
3     47.4610366821289   26.746612548828125  -35.898860931396484   
4  -1.2106596231460571  -19.012897491455078   19.568010330200195

I get this, which gives me the information I want. But I was wondering how you get the results to be printed all horizontally instead of having backslashes serve as an enter.

  network                  1                1.1                   2  ... 5
0    node                  1                  1                   1  ... 1
1    hemi                 lh                 rh                  lh  ... lh
2     NaN                NaN                NaN                 NaN  ... NaN
3       0  56.05574417114258  92.03103637695312   3.391575574874878  ... -35.898860931396484
4       1   55.5472526550293   43.6900749206543  -65.49598693847656  ... 19.568010330200195

Is this something achievable through code or is this some kind of setting issues I have to change on Pycharm?

Minho Cho
  • 21
  • 4
  • 1
    `pd.set_option('display.max_columns', None)` _only_ determines whether or not the column is displayed. You can add also set the display width (as show in [the accepted answer](/a/11711637/15497888)) _e.g._ `pd.set_option('display.width', None)` to make the DataFrame take up unlimited width (no line wrapping). Alternatively use `pd.set_option('display.expand_frame_repr', False)` (as demonstrated in [this answer](/a/25415404/15497888)) which should also allow the DataFrame to expand to full width without wrapping. – Henry Ecker Sep 06 '22 at 00:51

0 Answers0