Skip to content

Future error warning #27

@scicrow

Description

@scicrow

Traceback error caused by an empty string ' ' in a column when pandas expects float64.
It seems to suggest this is caused by pyblock. Script used attached below. Doesn't affect anything at the moment but does throw out the error.

Versions:
Running on WSL-Ubuntu
Python 3.12.3
Pandas 2.2.2
Maplotlib 3.8.4
Numpy 1.26.4

pyblock/pd_utils.py:105: FutureWarning: 
Setting an item of incompatible dtype is deprecated and will raise in a future error of pandas. 
Value '' has dtype incompatible with float64, please explicitly cast to a compatible dtype first.
  block_info.loc[:,loc] = ''

    #!/usr/bin/env python

"""
CALCULATE BLOCK STANDARD ERROR


"""
import numpy as np
import pyblock as pb
import matplotlib.pyplot as plt
import pandas as pd


def run_block(run_data):
    # RUN PYBLOCK AND GET OUPUT. BASED ON TUTORIAL
    reblock_data = pb.blocking.reblock(run_data)
    #for reblock_iter in reblock_data:
        #print(reblock_iter)
    
    # FIND OPTIMUM BLOCKS FOR REBLOCKING FUNCTION. EXPORT AS PD. DATAFRAME
    opt = pb.blocking.find_optimal_block(len(run_data), reblock_data)
    blocked_data = (reblock_data[opt[0]])
    pandas_data = pd.Series(run_data)
    #print(pandas_data.head())
    
    #DETERMINE NUMBER DATA POINTS AT EACH REBLOCK ITERATION
    (data_length, reblock_data, covariance) = pb.pd_utils.reblock(pandas_data)
    #print(data_length)
    print(reblock_data)
    pandas_reblock_data = pd.Dataframe(reblock_data)
    print(pandas_reblock_data)
    
    
    
def test_pyblock(N, L):
    '''Generate random correlated data containing 2^N data points.
       Randon data is convolved over a 2^L/10 length to give the 
       correlated signal.'''
    return np.convolve(np.random.randn(2**N), np.ones(2**L)/10, 'same')

def plot_chart(plot_data):
    '''Matplotlib plotting of data. Requires one arg.
        Mostly for testing.'''
    plt.plot(plot_data)
    plt.show()


rand_data = test_pyblock(16, 6)
run_block(rand_data)
    
 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions