Skip to content

Commit 19a5dca

Browse files
Update README.md
1 parent 18598b9 commit 19a5dca

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,3 +347,39 @@ def save_dataframe(df, filename):
347347
# Assuming df_data is your DataFrame and you want to save it as 'data'
348348
save_dataframe(df_data, './data/after-clean/complete_data')
349349
```
350+
351+
352+
### toggle pandas display settings
353+
```python
354+
def toggle_pandas_display_settings(mode='full'):
355+
"""
356+
Toggle the display settings of pandas DataFrame.
357+
358+
Parameters:
359+
- mode: 'full' to display DataFrames without truncation, 'default' to reset to default settings.
360+
361+
Example:
362+
363+
# To turn on full display:
364+
toggle_pandas_display_settings('full')
365+
366+
# To reset to default settings:
367+
toggle_pandas_display_settings('default')
368+
369+
"""
370+
if mode == 'full':
371+
# Set to display DataFrames without truncation
372+
pd.set_option('display.max_rows', None)
373+
pd.set_option('display.max_columns', None)
374+
pd.set_option('display.max_colwidth', None) # For pandas versions 1.0 and later
375+
# pd.set_option('display.max_colwidth', -1) # Uncomment for pandas versions before 1.0
376+
print("Pandas display settings set to full display mode.")
377+
elif mode == 'default':
378+
# Reset to pandas default display settings
379+
pd.reset_option('display.max_rows')
380+
pd.reset_option('display.max_columns')
381+
pd.reset_option('display.max_colwidth')
382+
print("Pandas display settings reset to default.")
383+
else:
384+
print("Invalid mode. Please choose 'full' or 'default'.")
385+
```

0 commit comments

Comments
 (0)