DataStore Quickstart

```
# All pandas .str methods work
ds['name_upper'] = ds['name'].str.upper()
ds['name_len'] = ds['name'].str.len()
ds['has_a'] = ds['name'].str.contains('a')
```

### DateTime Operations[​](#datetime-ops "Direct link to DateTime Operations")

```
# All pandas .dt methods work
ds['year'] = ds['date'].dt.year
ds['month'] = ds['date'].dt.month
ds['day_of_week'] = ds['date'].dt.dayofweek
```

### ClickHouse Extensions[​](#extensions "Direct link to ClickHouse Extensions")

```
# URL parsing (not available in pandas!)
ds['domain'] = ds['url'].url.domain()

# JSON extraction
ds['user_name'] = ds['json_data'].json.get_string('name')

# IP address operations
ds['is_ipv4'] = ds['ip_addr'].ip.is_ipv4_string()
```

## Best Practices[​](#best-practices "Direct link to Best Practices")

### 1. Use Parquet for Large Files[​](#use-parquet-for-large-files "Direct link to 1. Use Parquet for Large Files")

```
# CSV - slower, reads entire file
ds = pd.read_csv("large_data.csv")

# Parquet - faster, columnar format, reads only needed columns
ds = pd.read_parquet("large_data.parquet")
```

### 2. Filter Early[​](#filter-early "Direct link to 2. Filter Early")

```
# Good - filter first, then aggregate
result = (ds
    .filter(ds['date'] >= '2024-01-01')
    .groupby('category')['amount'].sum()
)

# Less optimal - aggregate first
result = ds.groupby('category')['amount'].sum()
```

### 3. Select Only Needed Columns[​](#select-only-needed-columns "Direct link to 3. Select Only Needed Columns")

```
# Good - select specific columns
result = ds.select('name', 'age', 'city').filter(ds['age'] > 25)

# Less optimal - work with all columns
result = ds.filter(ds['age'] > 25)
```

### 4. Use SQL for Complex Operations[​](#use-sql-for-complex-operations "Direct link to 4. Use SQL for Complex Operations")

```
# For complex queries, use SQL directly
ds = DataStore()
result = ds.sql("""
    SELECT category, 
           SUM(amount) as total,
           COUNT(*) as count,
           AVG(amount) as avg
    FROM file('sales.csv', 'CSVWithNames')
    WHERE date >= '2024-01-01'
    GROUP BY category
    HAVING total > 10000
    ORDER BY total DESC
    LIMIT 10
""")
```

## Next Steps[​](#next-steps "Direct link to Next Steps")

- Learn about all [Factory Methods](/docs/chdb/datastore/factory-methods) for creating DataStore
- Explore [Query Building](/docs/chdb/datastore/query-building) for SQL-style operations
- Check out [Accessors](/docs/chdb/datastore/accessors) for string, datetime, and more
- Read the [Performance Guide](/docs/chdb/guides/pandas-performance) for optimization tips

- [Installation](#installation)
  - [Verify Installation](#verify)- [One-Line Migration from Pandas](#migration)
    - [Migration Example](#migration-example)- [Basic Usage](#basic-usage)
      - [Creating a DataStore](#creating)- [Filtering Data](#filtering)- [Selecting Columns](#selecting)- [Sorting](#sorting)- [Grouping and Aggregation](#groupby)- [Joining DataStores](#joining)- [Getting Results](#results)
        - [Triggering Execution](#execution-triggers)- [Viewing Generated SQL](#view-sql)- [Working with Different Data Sources](#data-sources)
          - [Local Files](#local-files)- [Cloud Storage](#cloud-storage)- [Databases](#databases)- [String and DateTime Operations](#accessors)
            - [String Operations](#string-ops)- [DateTime Operations](#datetime-ops)- [ClickHouse Extensions](#extensions)- [Best Practices](#best-practices)
              - [1. Use Parquet for Large Files](#use-parquet-for-large-files)- [2. Filter Early](#filter-early)- [3. Select Only Needed Columns](#select-only-needed-columns)- [4. Use SQL for Complex Operations](#use-sql-for-complex-operations)- [Next Steps](#next-steps)

Was this page helpful?