小编Joh*_*vis的帖子

连接熊猫数据框中的两列

我的数据框看起来像 -

state        msg              value
aa          a,b,r              .22
bb          m,b,r             1.43
cc          a,b,q              .33
dd          h,h,f              .25
Run Code Online (Sandbox Code Playgroud)

我希望我的数据框看起来像 -

state        msg              value      text
aa          a,b,r              .22      a,b,r .22
bb          m,b,r             1.43      m,b,r 1.43
cc          a,b,q              .33      a,b,q .33
dd          h,h,f              .25      h,h,f .25
Run Code Online (Sandbox Code Playgroud)

我已经做好了 -

df.info()

 #   Column        Non-Null Count  Dtype 
---  ------        --------------  ----- 
 0   state         6925 non-null   object
 1   msg           6925 non-null   object
 2   value         6925 non-null   object

df['text'] = df['state'].astype(str).str.cat(df['value'], sep=' ')
Run Code Online (Sandbox Code Playgroud)

但得到这个错误 -

TypeError: Concatenation requires …
Run Code Online (Sandbox Code Playgroud)

python-3.x pandas scikit-learn

4
推荐指数
1
解决办法
295
查看次数

为什么断言错误有 numpy.ndarray

我的数据框看起来像 -

             can    sbi      bjf    srt      acc    amb     tata     jsw    hdfcl   sbil
Date                                        
2018-02-07  248.65  259.10  2298.40 1284.65 1313.75 200.30  560.95  313.25  457.65  667.90
2018-03-07  244.70  257.75  2321.50 1298.45 1336.80 200.85  566.50  311.80  459.65  669.90
2018-04-07  244.75  257.50  2331.95 1144.85 1352.65 201.15  568.90  312.00  459.60  664.60
2018-05-07  243.75  256.60  2329.45 1151.90 1388.95 207.30  553.50  310.40  462.05  663.15
2018-06-07  247.80  257.45  2341.70 1110.55 1373.45 207.35  554.15  309.30  468.90  667.40
2018-09-07  249.55  261.35  2346.60 1139.95 1375.90 206.40  556.85  312.95  474.30  664.90
2018-10-07 …
Run Code Online (Sandbox Code Playgroud)

python python-3.x pandas

4
推荐指数
1
解决办法
8268
查看次数

使用纬度和经度找出POI(2公里以内)

我有一个数据集,其中包含Zipcode以及lat和log.我想从该纬度和经度中找出医院/银行列表(2公里内).

怎么做?

Long/Lat数据看起来像

store_zip   lon lat
410710    73.8248981    18.5154681
410209    73.0907       19.0218215
400034    72.8148177    18.9724162
400001    72.836334     18.9385352
400102    72.834424     19.1418961
400066    72.8635299    19.2313448
400078    72.9327444    19.1570343
400078    72.9327444    19.1570343
400007    72.8133825    18.9618411
400050    72.8299518    19.0551695
400062    72.8426858    19.1593396
400083    72.9374227    19.1166191
400603    72.9781047    19.1834148
401107    72.8929       19.2762702
401105    72.8663173    19.3053477
400703    72.9992013    19.0793547
401209          NA          NA
401203    72.7983705    19.4166761
400612    73.0287209    19.1799265
400612    73.0287209    19.1799265
400612    73.0287209    19.1799265
Run Code Online (Sandbox Code Playgroud)

r latitude-longitude geocode ggmap

1
推荐指数
1
解决办法
227
查看次数