Home > Software engineering >  polars.dataframe sometimes displays dots instead of datas
polars.dataframe sometimes displays dots instead of datas

Time:05-06

when using polars.dataframe, it sometimes displays dots instead of actual datas. i dont know what im missing.(have no problem when using pandas). can can you tell me what i should do?

import polars as pl 
import pandas as pd

class new:
    xyxy = '124'

a = [[[0.45372647047042847, 0.7791867852210999, 0.05796612799167633, 
0.08813457936048508, 0.9122178554534912, 0, 'corn'],
[0.5337053537368774, 0.605276882648468, 0.043029140681028366, 0.06894499808549881, 
0.8814031481742859, 0, 'corn'],
[0.47244399785995483, 0.5134297609329224, 0.03258286789059639, 0.054770857095718384, 
0.8650641441345215, 0, 'corn'],
[0.4817340672016144, 0.42551395297050476, 0.02438574656844139, 0.04052922874689102, 
0.8646907806396484, 0, 'corn'], 
[0.5215370059013367, 0.4616119861602783, 0.027680961415171623, 0.04423023760318756, 
0.8433780670166016, 0, 'corn'],
[0.5168840885162354, 0.4077163636684418, 0.021290680393576622, 0.034322340041399, 
0.8073480129241943, 0, 'corn'], 
[0.4868599772453308, 0.3901885747909546, 0.01746474765241146, 0.02876533754169941, 
0.631712794303894, 0, 'corn'],
[0.5133631825447083, 0.3870452046394348, 0.014495659619569778, 0.02186509035527706, 
0.6174931526184082, 0, 'corn'],
[0.5155017375946045, 0.3974197208881378, 0.01627129688858986, 0.03393130749464035, 
0.4413506090641022, 0, 'corn']]]

ca = 'xmin', 'ymin', 'xmax', 'ymax', 'confidence', 'class', 'name'  # xyxy columns
cb = 'xcenter', 'ycenter', 'width', 'height', 'confidence', 'class', 'name'  # xywh 
columns

for k, c in zip(['xyxy', 'xyxyn', 'xywh', 'xywhn'], [ca, ca, cb, 
cb]):
    setattr(new, k, [pl.DataFrame(x, columns=c, orient="row") for x in a])
    #setattr(new, k, [pd.DataFrame(x, columns=c, orient="row") for x in a]) 

print (new.xyxy[0])

CodePudding user response:

Use polars.Config.set_tbl_rows to control the number of displayed rows:

pl.Config.set_tbl_rows(1000)
print(new.xyxy[0])

# Output
shape: (9, 7)
┌────────────────┬────────────────┬────────────────┬────────────────┬───────────────┬───────┬──────┐
│ xmin           ┆ ymin           ┆ xmax           ┆ ymax           ┆ confidence    ┆ class ┆ name │
│ ---            ┆ ---            ┆ ---            ┆ ---            ┆ ---           ┆ ---   ┆ ---  │
│ f64            ┆ f64            ┆ f64            ┆ f64            ┆ f64           ┆ i64   ┆ str  │
╞════════════════╪════════════════╪════════════════╪════════════════╪═══════════════╪═══════╪══════╡
│ 0.453726470470 ┆ 0.779186785221 ┆ 0.057966127991 ┆ 0.088134579360 ┆ 0.91221785545 ┆ 0     ┆ corn │
│ 42847          ┆ 0999           ┆ 67633          ┆ 48508          ┆ 34912         ┆       ┆      │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌┤
│ 0.533705353736 ┆ 0.605276882648 ┆ 0.043029140681 ┆ 0.068944998085 ┆ 0.88140314817 ┆ 0     ┆ corn │
│ 8774           ┆ 468            ┆ 028366         ┆ 49881          ┆ 42859         ┆       ┆      │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌┤
│ 0.472443997859 ┆ 0.513429760932 ┆ 0.032582867890 ┆ 0.054770857095 ┆ 0.86506414413 ┆ 0     ┆ corn │
│ 95483          ┆ 9224           ┆ 59639          ┆ 718384         ┆ 45215         ┆       ┆      │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌┤
│ 0.481734067201 ┆ 0.425513952970 ┆ 0.024385746568 ┆ 0.040529228746 ┆ 0.86469078063 ┆ 0     ┆ corn │
│ 6144           ┆ 50476          ┆ 44139          ┆ 89102          ┆ 96484         ┆       ┆      │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌┤
│ 0.521537005901 ┆ 0.461611986160 ┆ 0.027680961415 ┆ 0.044230237603 ┆ 0.84337806701 ┆ 0     ┆ corn │
│ 3367           ┆ 2783           ┆ 171623         ┆ 18756          ┆ 66016         ┆       ┆      │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌┤
│ 0.516884088516 ┆ 0.407716363668 ┆ 0.021290680393 ┆ 0.034322340041 ┆ 0.80734801292 ┆ 0     ┆ corn │
│ 2354           ┆ 4418           ┆ 576622         ┆ 399            ┆ 41943         ┆       ┆      │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌┤
│ 0.486859977245 ┆ 0.390188574790 ┆ 0.017464747652 ┆ 0.028765337541 ┆ 0.63171279430 ┆ 0     ┆ corn │
│ 3308           ┆ 9546           ┆ 41146          ┆ 69941          ┆ 3894          ┆       ┆      │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌┤
│ 0.513363182544 ┆ 0.387045204639 ┆ 0.014495659619 ┆ 0.021865090355 ┆ 0.61749315261 ┆ 0     ┆ corn │
│ 7083           ┆ 4348           ┆ 569778         ┆ 27706          ┆ 84082         ┆       ┆      │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌┤
│ 0.515501737594 ┆ 0.397419720888 ┆ 0.016271296888 ┆ 0.033931307494 ┆ 0.44135060906 ┆ 0     ┆ corn │
│ 6045           ┆ 1378           ┆ 58986          ┆ 64035          ┆ 41022         ┆       ┆      │
└────────────────┴────────────────┴────────────────┴────────────────┴───────────────┴───────┴──────┘
  • Related