How To Let Null Values Are Not Stored In Hbase In Pandas Python?
I have some sample data as below: test_a test_b test_c test_d test_date ------------------------------------------------- 1 a 500 0.1 111
Solution 1:
You should be able to do this by creating a custom function and calling that in your lambda function. For example you could have a function -
defmakeEntry(a, b, c):
entrydict = {}
## using the fact that NaN == NaN is supposed to be False and empty strings are Falsyif(a==a and a):
entrydict ["test:test_a"] = str(a)
if(b==b and b):
entrydict ["test:test_b"] = str(b)
if(c==c and c):
entrydict ["test:test_c"] = str(c)
return entrydict
and then you could change your apply function to -
df.apply(lambda row: b.put(row["k"],
makeEntry(row["test_a"],row["test_b"],row["test_c"])), axis=1)
This way you only put in values that are not NaN
instead of all values.
Post a Comment for "How To Let Null Values Are Not Stored In Hbase In Pandas Python?"