I am trying to find a similar functionality like in Python where in I can delete the rows which have ‘all’ null values in a row -
code in python - Using Pandas dataframe ‘closed_prices’
closed_prices.dropna(axis=0, how=‘all’, inplace=True)
Basically I want to drop rows which have missing values for all columns - I am using a stock data and want to remove the weekends and holidays, each column represent closing price of a particular stock. So if all the column values are null/missing for a particular row I want to delete that row.
I am using the below code -
using DataFrames
using DataFramesMeta
using CSV
using Dates
using Query
fh_5 = CSV.read("D:\\Julia_Dataframe\\JuliaCon2020-DataFrames-Tutorial\\fh_5yrs.csv", DataFrame)
min_date = minimum(fh_5[:, "date"])
max_date = maximum(fh_5[:, "date"])
date_seq = string.(collect(Dates.Date(min_date) : Dates.Day(1) : Dates.Date(max_date)))
date_range = df = DataFrame(dates = date_seq)
date_range.dates = Date.(date_range.dates, "yyyy-mm-dd")
for s in unique(fh_5.symbol)
df = fh_5[fh_5.symbol .== s, ["date","close"]]
date_range = leftjoin(date_range, df, on =:"dates" => :"date")
rename!(date_range, Dict(:close => s))
end
size(date_range, 1)
size(filter(x -> any(!ismissing, x), date_range), 1)
size(date_range, 1)