Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include curve unit in LASFile.df() column names #434

Open
issimo007 opened this issue Mar 30, 2021 · 3 comments
Open

Include curve unit in LASFile.df() column names #434

issimo007 opened this issue Mar 30, 2021 · 3 comments

Comments

@issimo007
Copy link

Hello, I tried looking around all day but couldn't find a way to use the "las.df()" command in a way that would generate a dataframe header that includes the "mnemonic (unit)". If anyone has a suggestion it is greatly appreciated. Thank you!

@kinverarity1 kinverarity1 self-assigned this Mar 31, 2021
@kinverarity1
Copy link
Owner

Thanks @issimo007 - that's a great suggestion for a feature! It's not available at the moment.

For now you could achieve what you want with this code instead of las.df()

def las_to_df_with_units(las):
    column_mapper = {
        c.mnemonic: f"{c.mnemonic} ({c.unit})"
        for c in las.curves
    }
    return (
        las.df()
        .reset_index()
        .rename(columns=column_mapper)
        .set_index(list(column_mapper.values())[0])
    )

import lasio.examples
las = lasio.examples.open("sample.las")
df = las_to_df_with_units(las)
print(df)
          DT (US/M)  RHOB (K/M3)  NPHI (V/V)  SFLU (OHMM)  SFLA (OHMM)  ILM (OHMM)  ILD (OHMM)
DEPT (M)                                                                                      
1670.000     123.45       2550.0        0.45       123.45       123.45       110.2       105.6
1669.875     123.45       2550.0        0.45       123.45       123.45       110.2       105.6
1669.750     123.45       2550.0        0.45       123.45       123.45       110.2       105.6

@issimo007
Copy link
Author

Thank you Kent! I couldn't figure out how to access the units once imported into lasio. All the best, Mauro.

@kinverarity1 kinverarity1 changed the title Data frame header with both Mnemonic and Unit Obtain as pd.DataFrame with mnemonic and unit in column name Apr 7, 2021
@kinverarity1 kinverarity1 changed the title Obtain as pd.DataFrame with mnemonic and unit in column name Include curve unit in LASFile.df() column names Apr 9, 2021
@kinverarity1
Copy link
Owner

This could be added to the LASFile.df method as a keyword argument e.g. LASFile.df(include_units=False).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants