我正在尝试从 csv 文件中删除 NaN 值,但我只想删除所有列均为空的行。下面附有我要删除的行的图片。
文件链接:https://filebin.net/ou93iqiinss02l0g https://filebin.net/ou93iqiinss02l0g
本质上,如果 B、C、D、E、F、G、H 列为 NaN,我会删除整行
我尝试使用下面的代码,但它删除了所有内容
import pandas as pd
df = pd.read_csv("testing.csv")
df = df.dropna(thresh = 7)
最终结果将如下所示
Data
,Open,High,Low,Close,Adj Close,Volume,Singapore
2015-10-01,2795.399902,3104.719971,2765.439941,2998.350098,2998.350098,0.0,
2015-11-01,2976.719971,3043.850098,2843.949951,2855.939941,2855.939941,0.0,
2015-12-01,2862.790039,2911.439941,2793.389893,2882.72998,2882.72998,0.0,
2016-01-01,2889.22998,2890.209961,2529.01001,2629.110107,2629.110107,0.0,
2016-02-01,2637.050049,2684.790039,2528.439941,2666.51001,2666.51001,0.0,
2016-03-01,2666.709961,2906.800049,2654.97998,2840.899902,2840.899902,0.0,
2016-04-01,2820.659912,2964.100098,2783.419922,2838.52002,2838.52002,158708700.0,
2016-05-01,2842.860107,2848.899902,2713.469971,2791.060059,2791.060059,0.0,
2016-06-01,2787.98999,2881.919922,2703.47998,2840.929932,2840.929932,0.0,
2016-07-01,2848.449951,2958.899902,2830.0,2868.689941,2868.689941,0.0,
2016-08-01,2875.590088,2898.27002,2810.8798829999996,2820.590088,2820.590088,0.0,
2016-09-01,2821.929932,2911.840088,2791.3798829999996,2869.469971,2869.469971,0.0,
2016-10-01,2879.850098,2901.72998,2783.330078,2813.8701170000004,2813.8701170000004,0.0,
2016-11-01,2814.080078,2915.419922,2760.969971,2905.169922,2905.169922,0.0,
2016-12-01,2913.649902,2980.77002,2857.909912,2880.76001,2880.76001,0.0,
2017-01-01,2887.0,3065.1298829999996,2869.659912,3046.800049,3046.800049,0.0,
2017-02-01,3045.939941,3138.969971,3030.649902,3096.610107,3096.610107,4018227800.0,
2017-03-01,3106.300049,3188.02002,3104.330078,3175.110107,3175.110107,5462555700.0,
2017-04-01,3180.27002,3189.810059,3113.899902,3175.439941,3175.439941,4292226700.0,
2017-05-01,3183.429932,3275.389893,3183.409912,3210.820068,3210.820068,5080433500.0,
2017-06-01,3214.1201170000004,3270.919922,3196.48999,3226.47998,3226.47998,4414015100.0,
2017-07-01,3228.909912,3354.709961,3196.139893,3329.52002,3329.52002,5085548600.0,
2017-08-01,3321.5,3349.090088,3244.22998,3277.26001,3277.26001,4856835500.0,
2017-09-01,3274.389893,3275.139893,3193.409912,3219.909912,3219.909912,3840282400.0,
2017-10-01,3233.949951,3392.149902,3230.810059,3374.080078,3374.080078,4261116400.0,
2017-11-01,3377.1899409999996,3449.320068,3341.300049,3433.540039,3433.540039,4789747800.0,
2017-12-01,3441.850098,3469.360107,3370.219971,3402.919922,3402.919922,3386126700.0,
2018-01-01,3406.4799799999996,3611.6899409999996,3403.8701170000004,3533.98999,3533.98999,4727173600.0,
2018-02-01,3536.929932,3574.5900880000004,3340.550049,3517.9399409999996,3517.9399409999996,6143735500.0,
2018-03-01,3493.4399409999996,3555.9799799999996,3382.780029,3427.969971,3427.969971,4963081900.0,
2018-04-01,3439.040039,3628.429932,3338.959961,3613.929932,3613.929932,4599803900.0,
2018-05-01,3624.1999509999996,3641.649902,3428.179932,3428.179932,3428.179932,5918362800.0,
2018-06-01,3423.5,3492.3400880000004,3237.77002,3268.699951,3268.699951,5500961400.0,
2018-07-01,3277.429932,3341.419922,3176.26001,3319.850098,3319.850098,5029346600.0,
2018-08-01,3331.050049,3347.97998,3187.830078,3213.47998,3213.47998,5005791600.0,
2018-09-01,3209.969971,3265.01001,3102.72998,3257.050049,3257.050049,4158150600.0,
2018-10-01,3262.429932,3272.8798829999996,2955.679932,3018.800049,3018.800049,5516696000.0,
2018-11-01,3045.679932,3132.419922,3007.310059,3117.610107,3117.610107,4457632700.0,
2018-12-01,3154.219971,3192.8798829999996,3000.449951,3068.76001,3068.76001,3627597800.0,
2019-01-01,3072.98999,3250.27002,2993.419922,3190.169922,3190.169922,4467841200.0,
2019-02-01,3194.219971,3286.080078,3174.0,3212.689941,3212.689941,3786000800.0,
2019-03-01,3210.840088,3251.719971,3156.790039,3212.8798829999996,3212.8798829999996,4128594600.0,
2019-04-01,3229.110107,3415.179932,3227.6201170000004,3400.1999509999996,3400.1999509999996,4447727600.0,
2019-05-01,3389.5200200000004,3397.179932,3110.51001,3117.76001,3117.76001,4319537800.0,
2019-06-01,3111.51001,3336.080078,3104.030029,3321.610107,3321.610107,4160448600.0,
2019-07-01,3339.580078,3386.649902,3299.889893,3300.75,3300.75,4489792100.0,
2019-08-01,3282.790039,3311.26001,3040.159912,3106.52002,3106.52002,5146051500.0,
2019-09-01,3092.25,3216.8701170000004,3074.040039,3119.98999,3119.98999,4116898900.0,
2019-10-01,3130.110107,3235.23999,3068.830078,3229.8798829999996,3229.8798829999996,4402690200.0,
2019-11-01,3227.600098,3285.719971,3182.050049,3193.919922,3193.919922,7055882400.0,
2019-12-01,3198.27002,3239.23999,3144.070068,3222.830078,3222.830078,4536740600.0,
2020-01-01,3230.47998,3283.889893,3144.100098,3153.72998,3153.72998,4951167700.0,
2020-02-01,3131.02002,3233.860107,3008.459961,3011.080078,3011.080078,5320489700.0,
2020-02-21,,,,,,,24.0
2020-02-25,,,,,,,
2020-02-28,,,,,,,22.0
2020-03-01,2988.350098,3047.790039,2208.419922,2481.22998,2481.22998,7767702900.0,
2020-03-02,,,,,,,
2020-03-03,,,,,,,
2020-03-06,,,,,,,23.0
2020-03-10,,,,,,,
2020-03-13,,,,,,,21.0
2020-03-17,,,,,,,
2020-03-20,,,,,,,24.0
2020-03-23,,,,,,,
2020-03-24,,,,,,,
2020-03-27,,,,,,,27.0
2020-03-30,,,,,,,
2020-03-31,,,,,,,
2020-04-01,2468.169922,2671.580078,2380.840088,2624.22998,2624.22998,7238328000.0,
2020-04-03,,,,,,,37.0
2020-04-06,,,,,,,
2020-04-07,,,,,,,
2020-04-10,,,,,,,73.0
2020-04-13,,,,,,,
2020-04-14,,,,,,,
2020-04-17,,,,,,,85.0
2020-04-20,,,,,,,
2020-04-21,,,,,,,
2020-04-24,,,,,,,90.0
2020-04-27,,,,,,,
2020-04-28,,,,,,,
2020-05-01,2555.669922,2611.73999,2489.939941,2510.75,2510.75,7367276100.0,90.0
2020-05-05,,,,,,,
2020-05-15,,,,,,,
2020-05-21,,,,,,,
2020-05-22,,,,,,,92.0
2020-05-25,,,,,,,
2020-05-26,,,,,,,
2020-05-30,,,,,,,
2020-06-01,2519.419922,2839.389893,2516.459961,2589.909912,2589.909912,8396435700.0,
2020-06-05,,,,,,,89.0
2020-06-08,,,,,,,
2020-06-15,,,,,,,
2020-06-16,,,,,,,
2020-06-19,,,,,,,92.0
2020-06-22,,,,,,,
2020-06-25,,,,,,,
2020-07-01,2604.080078,2707.669922,2511.02002,2529.820068,2529.820068,4876221500.0,
2020-07-03,,,,,,,
2020-07-06,,,,,,,
2020-07-07,,,,,,,90.0
2020-07-12,,,,,,,
2020-07-14,,,,,,,
2020-07-20,,,,,,,92.0
2020-07-26,,,,,,,
2020-07-27,,,,,,,
2020-07-31,,,,,,,
2020-08-01,2522.530029,2602.330078,2478.389893,2532.51001,2532.51001,6347053700.0,
2020-08-03,,,,,,,88.0
2020-08-07,,,,,,,
2020-08-10,,,,,,,
2020-08-12,,,,,,,
2020-08-14,,,,,,,90.0
2020-08-17,,,,,,,
2020-08-25,,,,,,,
2020-08-28,,,,,,,90.0
2020-08-31,,,,,,,
2020-09-01,2521.810059,2546.8701170000004,2476.820068,2490.090088,2490.090088,2000718800.0,
2020-09-11,2481.080078,2492.419922,2476.820068,2490.090088,2490.090088,0.0,