Error when i execute #Regression Model lm = sm.OLS(y_train, X_train).fit() lm.summary() in jupiter please help me solve it

#Regression Model
lm = sm.OLS(y_train, X_train).fit()
lm.summary()


ValueError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_6104\382809017.py in
1 #Regression Model
----> 2 lm = sm.OLS(y_train, X_train).fit()
3 lm.summary()

~\AppData\Roaming\Python\Python39\site-packages\statsmodels\regression\linear_model.py in init(self, endog, exog, missing, hasconst, **kwargs)
904 “An exception will be raised in the next version.”)
905 warnings.warn(msg, ValueWarning)
→ 906 super(OLS, self).init(endog, exog, missing=missing,
907 hasconst=hasconst, **kwargs)
908 if “weights” in self._init_keys:

~\AppData\Roaming\Python\Python39\site-packages\statsmodels\regression\linear_model.py in init(self, endog, exog, weights, missing, hasconst, **kwargs)
731 else:
732 weights = weights.squeeze()
→ 733 super(WLS, self).init(endog, exog, missing=missing,
734 weights=weights, hasconst=hasconst, **kwargs)
735 nobs = self.exog.shape[0]

~\AppData\Roaming\Python\Python39\site-packages\statsmodels\regression\linear_model.py in init(self, endog, exog, **kwargs)
188 “”"
189 def init(self, endog, exog, **kwargs):
→ 190 super(RegressionModel, self).init(endog, exog, **kwargs)
191 self._data_attr.extend([‘pinv_wexog’, ‘wendog’, ‘wexog’, ‘weights’])
192

~\AppData\Roaming\Python\Python39\site-packages\statsmodels\base\model.py in init(self, endog, exog, **kwargs)
265
266 def init(self, endog, exog=None, **kwargs):
→ 267 super().init(endog, exog, **kwargs)
268 self.initialize()
269

~\AppData\Roaming\Python\Python39\site-packages\statsmodels\base\model.py in init(self, endog, exog, **kwargs)
90 missing = kwargs.pop(‘missing’, ‘none’)
91 hasconst = kwargs.pop(‘hasconst’, None)
—> 92 self.data = self._handle_data(endog, exog, missing, hasconst,
93 **kwargs)
94 self.k_constant = self.data.k_constant

~\AppData\Roaming\Python\Python39\site-packages\statsmodels\base\model.py in _handle_data(self, endog, exog, missing, hasconst, **kwargs)
130
131 def _handle_data(self, endog, exog, missing, hasconst, **kwargs):
→ 132 data = handle_data(endog, exog, missing, hasconst, **kwargs)
133 # kwargs arrays could have changed, easier to just attach here
134 for key in kwargs:

~\AppData\Roaming\Python\Python39\site-packages\statsmodels\base\data.py in handle_data(endog, exog, missing, hasconst, **kwargs)
698
699 klass = handle_data_class_factory(endog, exog)
→ 700 return klass(endog, exog=exog, missing=missing, hasconst=hasconst,
701 **kwargs)

~\AppData\Roaming\Python\Python39\site-packages\statsmodels\base\data.py in init(self, endog, exog, missing, hasconst, **kwargs)
82 self.orig_endog = endog
83 self.orig_exog = exog
—> 84 self.endog, self.exog = self._convert_endog_exog(endog, exog)
85
86 self.const_idx = None

~\AppData\Roaming\Python\Python39\site-packages\statsmodels\base\data.py in _convert_endog_exog(self, endog, exog)
528 else:
529 exog_dtype = None
→ 530 raise ValueError(
531 "Pandas data cast to numpy dtype of object. Check input data "
532 “with np.asarray(data). The types seen were”

ValueError: Pandas data cast to numpy dtype of object. Check input data with np.asarray(data). The types seen wereNone and College.Name object
Accept int64
Enroll int64
Top10perc int64
Top25perc int64
F.Undergrad int64
P.Undergrad int64
Outstate int64
Room.Board int64
Books int64
Personal int64
PhD int64
Terminal int64
S.F.Ratio float64
perc.alumni int64
Expend int64
Grad.Rate int64
dtype: object. The data was
64 4186
680 2850
262 608
605 19873
495 2519

372 905
204 291
53 1646
294 1456
723 1231
Name: Apps, Length: 621, dtype: int64
and
College.Name Accept Enroll Top10perc
64 Brandeis University 2743 740 48
680 University of Southern Mississippi 2044 1046 20
262 Huntingdon College 520 127 26
605 University of California at Berkeley 8252 3215 95
495 Saint Joseph’s University 2003 776 39
… … … … …
372 Millsaps College 834 319 32
204 Fontbonne College 245 126 16
53 Bethune Cookman College 1150 542 12
294 King’s College 1053 381 20
723 Wartburg College 1074 345 34

 Top25perc  F.Undergrad  P.Undergrad  Outstate  Room.Board  Books  \

64 77 2819 62 19380 6750 410
680 50 9260 1387 4652 2470 500
262 47 538 126 8080 3920 500
605 100 19532 2061 11648 6246 636
495 71 2473 1314 12750 6350 350
… … … … … … …
372 61 1073 179 11320 4402 550
204 49 981 337 8390 4100 350
53 30 2128 82 5188 3396 650
294 45 500 541 10910 5160 400
723 66 1295 105 11600 3610 400

 Personal  PhD  Terminal  S.F.Ratio  perc.alumni  Expend  Grad.Rate  

64 1000 90 97 9.8 24 17150 84
680 500 78 99 18.7 23 5917 45
262 1100 63 72 11.4 9 7703 44
605 1933 93 97 15.8 10 13919 78
495 1690 84 90 17.4 13 8243 83
… … … … … … … …
372 1350 82 89 12.7 38 11218 58
204 1500 45 55 21.5 24 4607 62
53 2500 48 48 13.8 9 6817 58
294 1795 66 72 15.6 37 7649 87
723 850 66 91 12.4 37 7735 67

[621 rows x 17 columns]
before. After,
[ 4186 2850 608 19873 2519 285 2096 10634 857 3050 2799 1641
7122 2968 450 1005 662 2281 222 1709 11115 3440 392 5996
3847 1576 962 793 922 1458 4255 235 12749 668 578 1399
502 1603 605 4400 2994 582 563 3041 1151 10705 883 1947
3315 1038 321 1910 943 1083 3713 1046 560 692 14596 2702
1465 1025 478 1262 434 860 427 765 15698 587 861 443
6548 10706 5597 2095 7811 1209 674 1797 233 5892 848 888
4777 1721 1320 633 727 3140 571 1549 1196 1386 1877 465
759 979 7294 1981 1267 377 700 1618 15712 1216 3550 360
1310 1611 1891 12229 900 1127 713 3500 1257 7259 6574 616
1489 1470 9735 2961 3035 1738 20192 549 1538 996 16587 2417
6011 1380 1690 920 3877 18114 10477 880 1047 2593 464 2172
19152 800 878 1465 787 2286 2442 2088 1133 2139 5152 1496
3580 7548 4076 4471 1858 1777 2643 1202 3366 3151 5659 882
8598 519 6502 450 1558 1381 7888 4044 5244 4010 8766 3281
589 462 368 1480 2083 15849 1422 1110 809 13528 1464 6118
1190 1756 2267 2097 8681 484 2768 619 212 440 342 5095
548 823 457 2967 2013 1768 949 2747 910 1334 2540 1208
1107 6397 353 6773 4540 1321 805 1606 8000 4192 663 5549
469 3712 4800 7117 7700 1650 2362 1160 544 4095 855 5803
486 440 9478 2153 1734 2491 2161 1754 480 7875 9643 935
6277 21804 1305 281 48094 950 4856 2807 3821 510 1132 2974
876 3540 3793 1660 3767 1232 7837 4345 202 1351 626 213
1307 4019 1879 500 555 1220 5785 2887 1597 2848 1910 681
7663 1847 546 903 458 695 8384 3624 2459 472 441 2029
1563 361 1339 325 2762 809 14474 497 792 4418 3596 990
967 7791 261 1428 11023 1616 3304 1377 831 2929 817 1742
191 1566 495 4158 1712 497 247 174 1283 700 100 602
3207 452 461 936 5653 467 979 11220 7654 5191 1584 2496
586 2729 776 663 8399 12512 3325 1239 2409 1800 81 1243
1121 2220 696 8506 927 1784 4302 3330 263 335 1082 9750
318 12289 13789 6756 1109 1800 1164 444 516 1401 348 1457
1861 12809 6071 560 2302 11901 833 572 4216 948 5548 540
659 11651 2039 1860 535 4144 3934 1109 6855 600 420 529
1004 437 1154 2707 587 2989 6348 14939 4019 946 1205 1712
1013 2190 379 3150 331 785 5530 941 1154 3466 477 627
701 804 699 1660 232 2421 257 959 910 947 2753 14446
651 1340 8728 5081 434 601 5187 355 1243 1432 5661 818
2324 1758 647 3844 5139 1179 872 897 4877 369 313 1680
7428 1244 810 2425 3014 2320 4731 3347 1561 14463 2774 895
2119 7693 1420 599 920 5818 553 3058 2174 1756 584 346
7759 4996 584 374 484 2212 2308 4963 632 3100 5042 938
280 2519 4293 672 1416 440 838 2135 1170 314 2186 1743
8579 2197 1966 838 4522 13865 980 689 4784 3294 1576 6040
499 6411 14292 2688 576 3073 516 2096 758 12394 2939 608
244 4226 4681 848 193 8474 1732 1368 974 663 817 3646
2075 141 9239 3820 4217 7033 1130 1979 2336 2694 510 8256
807 2925 1208 1747 3495 2306 1487 1455 682 460 2087 4772
213 875 1006 494 5702 12445 1444 13218 735 602 417 1681
11054 2100 9167 1801 489 461 1011 15039 2936 9402 1006 5220
874 2397 2227 1006 940 594 662 8587 7473 761 995 5165
11223 1445 2777 8586 905 291 1646 1456 1231]
[[‘Brandeis University’ 2743 740 … 24 17150 84]
[‘University of Southern Mississippi’ 2044 1046 … 23 5917 45]
[‘Huntingdon College’ 520 127 … 9 7703 44]

[‘Bethune Cookman College’ 1150 542 … 9 6817 58]
[“King’s College” 1053 381 … 37 7649 87]
[‘Wartburg College’ 1074 345 … 37 7735 67]].

I think it’s complaining that there’s a college name that’s None or some null value.

By the way, to preserve the formatting in posts, please select any code or traceback and click the </> button because otherwise it’s very hard to read.