I'm relatively new to R, so hopefully this is an easy fix.
Here's my problem:
x <- data.frame(c("Thing1", "Thing2", "Thing3", "Thing4", "Thing5"), c("Sizeable line of text", "more text", "I hope this aligns", "something", "help me"))
colnames(x) <- c("T", "Text")
format(x, justify = "left")
T Text
1 Thing1 Sizeable line of text
2 Thing2 more text
3 Thing3 I hope this aligns
4 Thing4 not much
5 Thing5 help me
How can I get the column names to align left with the rest of the dataframe?
Thanks in advance.
In order to align columns to left in pandas dataframe, we use the dataframe. style. set_properties() function.
Align two objects on their axes with the specified join method. Join method is specified for each axis Index. Align on index (0), columns (1), or both (None). Broadcast across a level, matching Index values on the passed MultiIndex level.
# print object explicitly
print(x,right=F)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With